Android Studio中的Facebook sdk导致没有发现资源错误

时间:2017-10-31 14:17:17

标签: android android-studio android-gradle facebook-android-sdk

将Facebook sdk添加到我的应用程序导致此错误,无法解决此问题。请查看以下文件。

build.gradle文件

    apply plugin: 'com.android.application'

dependencies {
    compile fileTree(include: '*.jar', dir: 'libs')
    compile 'com.android.support:support-v4:27.0.0'
    compile('com.facebook.android:facebook-android-sdk:4.23.0') {
        exclude group: 'com.android.support', module: 'cardview-v7'
        exclude group: 'com.android.support', module: 'appcompat-v7'
        exclude group: 'com.android.support', module: 'support-v4'
        exclude group: 'com.android.support', module: 'customtabs'
    }
}

android {

    compileSdkVersion 25
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.android.example"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 2
        versionName "2.0"
    }

    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')
    }
}

repositories {
    maven {
        url 'https://maven.google.com/'
        name 'Google'
    }
    mavenCentral()
}

日志:

Information:Gradle tasks [clean, :PoetOnline:generateDebugSources, :PoetOnline:generateDebugAndroidTestSources, :PoetOnline:mockableAndroidJar]
/Users/rreddy2/.gradle/caches/transforms-1/files-1.1/facebook-android-sdk-4.23.0.aar/daccb1edfaff8ad182af08f6dd069933/res/values/values.xml
Error:(26, 5) error: resource android:attr/fontStyle not found.
Error:(26, 5) error: resource android:attr/font not found.
Error:(26, 5) error: resource android:attr/fontWeight not found.
Error:resource style/Theme.AppCompat.NoActionBar (aka com.shi3r.poetonline:style/Theme.AppCompat.NoActionBar) not found.
Error:resource style/Theme.AppCompat.Dialog (aka com.shi3r.poetonline:style/Theme.AppCompat.Dialog) not found.
/Users/rreddy2/Documents/Work/Source Codes/Poetonline Android/PoetOnlineWorkspace/PoetOnlineWorkspace/PoetOnline/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
Error:(49) resource android:attr/fontStyle not found.
Error:(49) resource android:attr/font not found.
Error:(49) resource android:attr/fontWeight not found.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':PoetOnline:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 3s
Information:13 errors
Information:0 warnings
Information:See complete output in console

1 个答案:

答案 0 :(得分:2)

我认为您必须删除括号(compile 'com.facebook.android:facebook-android-sdk:4.23.0')

compile 'com.facebook.android:facebook-android-sdk:4.23.0'

然后如果它不起作用,请尝试添加此版本并检查

compile 'com.facebook.android:facebook-android-sdk:4.6.0'