Murat Ayan
Murat Ayan

Reputation: 575

Facebook SDK 3.23.0 with Android Studio 1.1.0

First of all, when I try to add it with "import module" and then "add dependency" I get the error:

Error:(19, 0) Could not find property 'ANDROID_BUILD_MIN_SDK_VERSION' on project ':facebook'.

So I went ahead and created a gradle.properties file in the facebook module folder, then it gives me this error:

Error:(111, 0) Cannot call getBootClasspath() before setTargetInfo() is called.

For this I couldn't even find a similar problem on the web. Afterwards I tried to import it with maven. I followed the instructions on https://developers.facebook.com/quickstarts/ my build.gradle file:

repositories { mavenCentral() }


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile files('libs/bolts-android-1.1.4.jar')
    compile files('libs/Parse-1.8.2.jar')
    compile files('libs/ParseCrashReporting-1.8.2.jar')
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
}

And the error I got is:

Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild UP-TO-DATE :app:compileDebugNdk UP-TO-DATE :app:checkDebugManifest :app:preReleaseBuild UP-TO-DATE :app:prepareComAndroidSupportAppcompatV72103Library UP-TO-DATE :app:prepareComAndroidSupportSupportV42103Library UP-TO-DATE :app:prepareComFacebookAndroidFacebookAndroidSdk3211Library UP-TO-DATE :app:prepareDebugDependencies :app:compileDebugAidl UP-TO-DATE :app:compileDebugRenderscript UP-TO-DATE :app:generateDebugBuildConfig UP-TO-DATE :app:generateDebugAssets UP-TO-DATE :app:mergeDebugAssets UP-TO-DATE :app:generateDebugResValues UP-TO-DATE :app:generateDebugResources UP-TO-DATE :app:mergeDebugResources UP-TO-DATE :app:processDebugManifest UP-TO-DATE :app:processDebugResources UP-TO-DATE :app:generateDebugSources UP-TO-DATE :app:compileDebugJava :app:preDexDebug UP-TO-DATE :app:dexDebug UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Lbolts/AggregateException; at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596) at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554) at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171) at com.android.dx.merge.DexMerger.merge(DexMerger.java:189) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303) at com.android.dx.command.dexer.Main.run(Main.java:246) at com.android.dx.command.dexer.Main.main(Main.java:215) at com.android.dx.command.Main.main(Main.java:106) Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_45\bin\java.exe'' finished with non-zero exit value 2 Information:BUILD FAILED Information:Total time: 4.234 secs Information:1 error Information:0 warnings Information:See complete output in console

From what I saw in other similar questions, I thought maybe both facebook and parse are trying to compile bolts-android-1.1.4.jar and I commented it out but nothing changed.

I am working on this 8 hours straight now, so any help is appreciated.

Upvotes: 1

Views: 7091

Answers (4)

android developer
android developer

Reputation: 115972

This is a known issue , which is fixed by updating gradle to :

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

credit to this post.

Upvotes: 8

Rohit Chandekar
Rohit Chandekar

Reputation: 51

you can Refer https://stackoverflow.com/a/28697252/2657401

This solve my problem for Facebook in Android Studio 1.1.0

Upvotes: 0

Max Worg
Max Worg

Reputation: 2972

I had a similiar issue and I thought it was Facebook since it happened around the time I added their newest sdk to my dependencies in gradle.build but 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.

Upvotes: 2

Murat Ayan
Murat Ayan

Reputation: 575

Just take the maven way, your app's build.gradle should look like this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    //    compile files('libs/bolts-android-1.1.4.jar')
    //    compile files('libs/Parse-1.8.2.jar')
    //    compile files('libs/ParseCrashReporting-1.8.2.jar')
}

And then in the terminal window go to your project's directory and type:

gradlew.bat clean

Reboot the Android Studio and you should good to go.

Upvotes: 3

Related Questions