': Application: transformClassesWithDexForDebug. > com.android.build.transform.api.TransformException: when I added the latest version of the Facebook SDK in my studio project

I get an error when I try to add Facebook as a library or as gradle

//compile 'com.facebook.android:facebook-android-sdk:4.7.0' 

Here is my Android studio project structure in my main App gradle folder has the following library.

  compile fileTree(include: ['*.jar'], dir: 'libs') compile project(':twitter-core-release') compile project(':tweet-ui-release') compile project(':twitter-release') compile project(':tweet-composer-release') //compile 'com.facebook.android:facebook-android-sdk:4.7.0' compile project(':facebook_sk') compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.android.support:design:23.0.1' compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' compile 'com.squareup.retrofit:converter-jackson:2.0.0-beta1' compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1' compile 'com.twotoasters.jazzylistview:library:1.2.1' compile 'com.twotoasters.jazzylistview:library-recyclerview:1.2.1' compile 'com.pnikosis:materialish-progress:1.7' compile 'com.google.android.gms:play-services-gcm:8.1.0' compile 'com.android.support:recyclerview-v7:23.0.1' compile 'io.realm:realm-android:0.82.2' compile 'com.google.android.gms:play-services-analytics:8.1.0' compile 'jp.wasabeef:recyclerview-animators:1.3.0' compile 'com.google.code.gson:gson:2.3' compile 'io.fabric.sdk.android:fabric: 1.3.+@aar ' compile 'com.digits.sdk.android:digits: 1.7.+@aar ' 

there is generic-image-loader-1.9.4.jar in my libs application

and in facebook_sk it has the following

 dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' //compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.android.support:support-v4:23.0.1' } 

in facebook libs it has bolts-android-1.1.2.jar

if I deleted facebook skd and built my project, then it works fine in the studio, but when I can not facebook sdk, then it gives me the following error:

 Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2 

Do i need to use multidex?

+5
source share
3 answers

At the moment, I solved the problem by adding multidex

 defaultConfig { applicationId "com.xxxxx" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" // Enabling multidex support. multiDexEnabled true } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile project(':twitter-core-release') compile project(':tweet-ui-release') compile project(':twitter-release') compile project(':tweet-composer-release') //compile 'com.facebook.android:facebook-android-sdk:4.7.0' compile project(':facebook_sk') compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' compile 'com.squareup.retrofit:converter-jackson:2.0.0-beta1' compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta1' compile 'com.twotoasters.jazzylistview:library:1.2.1' compile 'com.twotoasters.jazzylistview:library-recyclerview:1.2.1' compile 'com.pnikosis:materialish-progress:1.7' compile 'com.google.android.gms:play-services-gcm:8.1.0' compile 'com.google.android.gms:play-services-analytics:8.1.0' compile 'io.realm:realm-android:0.82.2' compile 'jp.wasabeef:recyclerview-animators:1.3.0' compile 'com.google.code.gson:gson:2.3' compile 'io.fabric.sdk.android:fabric: 1.3.+@aar ' compile 'com.digits.sdk.android:digits: 1.7.+@aar ' compile 'com.android.support:multidex:1.0.1' } 

And for Facebook sdk:

 dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' //compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.android.support:support-v4:23.0.1' compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.android.support:design:23.0.1' compile 'com.android.support:recyclerview-v7:23.0.1' } 
+10
source

I get the same error when I have duplicate dependencies with different versions.

Try this command and check if there is something twice:

 gradle dependencies 
+3
source

I had to enable multiDex and assign javaMaxHeapSize "4g", otherwise I got an outofmemory error.

You need the following in the app build gradle file, inside android, defaultConfig already exists, you just need to add multiDexEnabled true there, dexOptions is new.

 defaultConfig { multiDexEnabled true } dexOptions { javaMaxHeapSize "4g" } 
0
source

Source: https://habr.com/ru/post/1233578/


All Articles