gpt4 book ai didi

android - 无法将Facebook SDK添加为Android Studio中的依赖项

转载 作者:行者123 更新时间:2023-12-03 05:15:22 25 4
gpt4 key购买 nike

这是我得到的错误:

错误:(14,13)无法解决:com.facebook.android:facebook-android-sdk:4.6.0在“项目结构”对话框的FileShow中显示

尽管我确保未选中gradle设置中的“脱机工作”复选框,但在Gradle控制台中可以看到它正在本地SDK库中寻找lib。

这是我的build.gradle文件:

buildscript {
repositories {
jcenter()
mavenCentral()

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


apply plugin: 'com.android.application'

dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
}

android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
targetSdkVersion 23
}
productFlavors {
}
}

有什么想法我该怎么办?

enter image description here

最佳答案

您需要在应用程序级别的build.grade中执行此操作

buildscript {
repositories {
jcenter()
mavenCentral()

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

而这个在build.grade在应用程序级别的文件夹中
apply plugin: 'com.android.application'

dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile 'com.google.android.gms:play-services-identity:8.1.0'
compile 'com.google.android.gms:play-services-gcm:8.1.0'
}

android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')

// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
defaultConfig {
targetSdkVersion 23
}
productFlavors {
}
}

关于android - 无法将Facebook SDK添加为Android Studio中的依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32876968/

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