gpt4 book ai didi

添加 Facebook SDK 时 Android Studio Gradle 构建错误

转载 作者:太空宇宙 更新时间:2023-11-03 11:56:42 32 4
gpt4 key购买 nike

您好,在将 facebook sdk 添加到我的项目时出现以下错误尝试了以下帖子为 facebook sdk 配置 gradle 脚本

link

Error:(111) A problem occurred evaluating project ':facebook'.
> Cannot call getBootClasspath() before setTargetInfo() is called.

这是我的 facebook 模块 gradle 脚本

apply plugin: 'com.android.library'

repositories {
mavenCentral()
}

project.group = 'com.facebook.android'

dependencies {
compile 'com.android.support:support-v4:[21,22)'
compile 'com.parse.bolts:bolts-android:1.1.4'
}

android {
compileSdkVersion 22
buildToolsVersion "22.0.0"

defaultConfig {
minSdkVersion 18
targetSdkVersion 22
}

lintOptions {
abortOnError false
}

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}

apply plugin: 'maven'
apply plugin: 'signing'

def isSnapshot = version.endsWith('-SNAPSHOT')
def ossrhUsername = hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
def ossrhPassword = hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""

task setVersion {
// The version will be derived from source
project.version = null
def sdkVersionFile = file('src/com/facebook/FacebookSdkVersion.java')
sdkVersionFile.eachLine{
def matcher = (it =~ /(?:.*BUILD = \")(.*)(?:\".*)/)
if (matcher.matches()) {
project.version = matcher[0][2]
return
}
}
if (project.version.is('unspecified')) {
throw new GradleScriptException('Version could not be found.', null)
}
}

uploadArchives {
repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
name 'Facebook-Android-SDK'
artifactId = 'facebook-android-sdk'
packaging 'aar'
description 'Facebook Android SDK'
url 'https://github.com/facebook/facebook-android-sdk'

scm {
connection 'scm:git@github.com:facebook/facebook-android-sdk.git'
developerConnection 'scm:git@github.com:facebook/facebook-android-sdk.git'
url 'https://github.com/facebook/facebook-android-sdk'
}

licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'https://github.com/facebook/facebook-android-sdk/blob/master/LICENSE.txt'
distribution 'repo'
}
}

developers {
developer {
id 'facebook'
name 'Facebook'
}
}
}
}
}

uploadArchives.dependsOn(setVersion)

signing {
required { !isSnapshot && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}

artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}

afterEvaluate {
androidJavadocs.classpath += project.android.libraryVariants.toList().first().javaCompile.classpath
}

请帮忙....

最佳答案

您的问题:在调用 setTargetInfo() 之前无法调用 getBootClasspath()。,我相信这里已经解决了:

http://tools.android.com/tech-docs/new-build-system

Android 构建工具 1.1.0 造成了这个问题,他们在 1.1.1 中修复了它:

1.1.1 (2015/02/24)

  • Only variants that package a Wear app will now trigger building them.

  • Dependency related issues now fail at build time rather than at debug time.

  • This is to allow running diagnostic tasks (such as 'dependencies') to help resolve the conflict.

  • Calling android.getBootClasspath() is now possible again.

请升级到:classpath 'com.android.tools.build:gradle:1.2.3',例如:

buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}

关于添加 Facebook SDK 时 Android Studio Gradle 构建错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29187973/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com