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