android - Gradle build failure when trying to use Facebook SDK -


i trying use facebook sdk in project in android studio. following step 3 of this tutorial. when try run app, "gradle: execution failed task ':facebookapp:dexdebug'." error. below output if error

gradle: execution failed task ':facebookapp:dexdebug'. 

failed run command: c:\android-sdk\build-tools\18.0.0\dx.bat --dex --output c:\users\brandon\androidstudioprojects\facebookappproject\facebookapp\build\libs\facebookapp-debug.dex c:\users\brandon\androidstudioprojects\facebookappproject\facebookapp\build\classes\debug c:\users\brandon\androidstudioprojects\facebookappproject\facebookapp\build\dependency-cache\debug c:\users\brandon\androidstudioprojects\facebookappproject\facebookapp\build\exploded-bundles\facebookappprojectlibrariesfacebookunspecified.aar\classes.jar c:\users\brandon\androidstudioprojects\facebookappproject\facebookapp\build\exploded-bundles\facebookappprojectlibrariesfacebookunspecified.aar\libs\android-support-v4.jar c:\android-sdk\extras\android\m2repository\com\android\support\support-v4\13.0.0\support-v4-13.0.0.jar error code: 1 output: unexpected top-level exception: java.lang.illegalargumentexception: added: landroid/support/v4/accessibilityservice/accessibilityserviceinfocompat$accessibilityserviceinfoicsimpl; @ com.android.dx.dex.file.classdefssection.add(classdefssection.java:123) @ com.android.dx.dex.file.dexfile.add(dexfile.java:163) @ com.android.dx.command.dexer.main.processclass(main.java:490) @ com.android.dx.command.dexer.main.processfilebytes(main.java:459) @ com.android.dx.command.dexer.main.access$400(main.java:67) @ com.android.dx.command.dexer.main$1.processfilebytes(main.java:398) @ com.android.dx.cf.direct.classpathopener.processarchive(classpathopener.java:245) @ com.android.dx.cf.direct.classpathopener.processone(classpathopener.java:131) @ com.android.dx.cf.direct.classpathopener.process(classpathopener.java:109) @ com.android.dx.command.dexer.main.processone(main.java:422) @ com.android.dx.command.dexer.main.processallfiles(main.java:333) @ com.android.dx.command.dexer.main.run(main.java:209) @ com.android.dx.command.dexer.main.main(main.java:174) @ com.android.dx.command.main.main(main.java:91) 1 error; aborting

here build.gradle facebook module:

buildscript {     repositories {         maven { url 'http://repo1.maven.org/maven2' }     }     dependencies {         classpath 'com.android.tools.build:gradle:0.5.+'     } }  apply plugin: 'android-library'  dependencies {     compile files('libs/android-support-v4.jar') }  android {     compilesdkversion 18     buildtoolsversion "18.0.0"      defaultconfig {         minsdkversion 7         targetsdkversion 16     }      sourcesets {         main {             manifest.srcfile 'androidmanifest.xml'             java.srcdirs = ['src']             resources.srcdirs = ['src']             res.srcdirs = ['res']         }     } } 

and build.gradle project:

buildscript {     repositories {         mavencentral()     }     dependencies {         classpath 'com.android.tools.build:gradle:0.5.+'     } } apply plugin: 'android'  repositories {     mavencentral() }  dependencies {     compile 'com.android.support:support-v4:13.0.+'     compile project(':libraries:facebook') }  android {     compilesdkversion 18     buildtoolsversion "18.0.0"      defaultconfig {         minsdkversion 7         targetsdkversion 16     } } 

am doing wrong?

you're adding android support library twice, resulting in dex merge conflict. main project refers maven library 'com.android.support:support-v4:13.0.+' , facebook project refers files('libs/android-support-v4.jar'). gradle cannot resolve conflicts between local jar files, must refer them through maven.

modify dependencies section of facebook build.gradle to:

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

and should work.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -