Gradle build failure when trying to use Facebook SDK

前端 未结 3 1254
误落风尘
误落风尘 2020-12-11 18:26

I am trying to use the Facebook SDK in a project in Android Studio. I am following step 3 of this tutorial. When I try to Run the app, I get a \"Gradle: Execution failed for

相关标签:
3条回答
  • 2020-12-11 18:31

    You're adding the android support library twice, resulting in a dex merge conflict. Your main project refers to the maven library with 'com.android.support:support-v4:13.0.+' and your Facebook project refers to it with files('libs/android-support-v4.jar'). Gradle cannot resolve conflicts between local jar files, so you must refer to them through maven.

    Modify the dependencies section of your Facebook build.gradle to:

    dependencies {
        compile 'com.android.support:support-v4:13.0.+'
    }
    

    and everything should work.

    0 讨论(0)
  • 2020-12-11 18:32

    In android studio, this is how I include a support library and facebook SDK. I'm supporting API 15+.

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'fr.avianey:facebook-android-api:+@aar'
        compile 'com.android.support:support-v13:20.0.0'
        ...
    }
    
    0 讨论(0)
  • 2020-12-11 18:55

    I had a similiar issue and it was just plain oversight on my part. I had conflicting versions of com.android.tools.build:gradle:1.1.2 and 1.1.1 inside two different gradle.build files.

    app/gradle.build

    dependencies {
        ...
        compile 'com.android.tools.build:gradle:1.1.2'
        ...
    }
    

    top-level gradle.build

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

    I commented out the line in my project's gradle.build file, ran gradlew clean from the command line, restarted Android Studio and then order was restored in the universe.

    0 讨论(0)
提交回复
热议问题