Carlos Alberto Murillo
Carlos Alberto Murillo

Reputation: 647

com.android.ide.common.internal.LoggedErrorException with Facebook SDK

I have my project which works well, if I add the Facebook SDK generates a com.android.ide.common.internal.LoggedErrorException error trying to compile.

I tried Maven Repository, and downloading the SDK Facebook, and both generate the same error.

This is the Gradle dependencies:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':simple-crop-image-lib')
    compile project(path: ':backend', configuration: 'android-endpoints')
    compile project(':httpclient-4.3.6')
    compile project(':httpmime-4.3.6')
    compile project(':httpcore-4.3.3')
    compile 'com.android.support:support-v13:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.koushikdutta.async:androidasync:1.3.8'
    compile 'com.koushikdutta.ion:ion:1.3.8'
    compile 'joda-time:joda-time:2.5'
    compile project(':facebook')
}

This is the implementation:

public class extends Activity implements Register GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
// Facebook
UiLifecycleHelper private uiHelper;
// Facebook
...

This is the error:

Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\AndroidSDK\sdk\build-tools\android-4.4W\dx.bat --dex --no-optimize --output C:\Carlos\RingProyect\app\build\intermediates\dex\debug C:\Carlos\RingProyect\app\build\intermediates\classes\debug C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\internal_impl-21.0.3-4959d6dabe32e10086d95451adf02b3105bb3b29.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\support-annotations-21.0.3-56620581d48b4e53a66e3c8171c6371387ca27a8.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\google-http-client-jackson2-1.19.0-4208b75ca9c39f13f0c833eca04c03cccea3f2e9.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\google-api-client-android-1.19.0-6de6f1752dfdd2f7269c5ebca750e463fe8698ae.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\google-http-client-android-1.19.0-d9ae92c3b3d0ecb599461daf2dbe3a955a59050c.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\classes-b173979dafb65381366219767cf55b3e9e853bfb.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\httpmime-4.3.6-3b37b68d78d793feb8401b62cba7fe2f3f74d83e.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\jsr305-1.3.9-5835e3ee0aa80174a87d682a1e9ffcf7a1101135.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\backend-android-endpoints-45d7cd94042d13a69dfe65cf4638db4471013ac2.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\bolts-android-1.1.4-c04175b72096a6e529ed3f71be91a0769e5aecc7.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\google-oauth-client-1.19.0-52a247687c1596598d7413aaf2a29a8947f5f9cd.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\classes-618f0879a780d0e2d8493552e69b3aa604718225.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\internal_impl-21.0.3-94cad900d13cd2a8d5402d289f28bf2747ccbb61.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\gson-2.3-00039b6a743aa0b577b54b85bab1bcfc5a7c7b5d.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\ion-1.3.8-c640a934021d1f39ad2302f380213f6675f4c278.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\google-api-client-1.19.0-ca416295d5a4743f0738ad9dda16a0e296002541.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\httpcore-4.3.3-7246717c88c5d5838e28cb71eab459038d9ba082.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\jackson-core-2.1.3-8ad8725d3275e0c9a6b240e2a5f42dd1c2fb1210.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\google-http-client-1.19.0-02d081b8be1f9b1dfa30f2ba2d5c5c1033e658f5.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\androidasync-1.3.8-99b85ea5cf8a58339ff45f563bce47553aff5c76.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\httpclient-4.3.6-b5358e8cf388d9b6d935e6ef384c38dee7488132.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\classes-aea9760e3da7b065e05c295f56b2354397f9bd28.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\classes-84c7f062264b457888f7dfb250e8626fc109a367.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\joda-time-2.5-33520e1d27f87b5291ecc6a8f93b7942b8aac0d1.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\guava-jdk5-13.0-2290d8749c87dfefb9fac2fcfe45a91d08c812cc.jar C:\Carlos\RingProyect\app\build\intermediates\pre-dexed\debug\classes-2d5075d9f95c61464dc534a8eefd9438d8a44d5a.jar Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536 at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:501) at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276) at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:490) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:167) at com.android.dx.merge.DexMerger.merge(DexMerger.java:188) at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287) at com.android.dx.command.dexer.Main.run(Main.java:230) at com.android.dx.command.dexer.Main.main(Main.java:199) at com.android.dx.command.Main.main(Main.java:103)

Thanks for the help.

Upvotes: 3

Views: 3033

Answers (1)

Carlos Alberto Murillo
Carlos Alberto Murillo

Reputation: 647

Well, I find the solution, the problem is specified by this line:

TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536

when I added Facebook Libraries, I got more than 65536 methods, and that is the limit, then we must optimize the code:

First if you are using Google Play Services:

Change :

compile 'com.google.android.gms:play-services:6.5.87'

For only the services that you wana use, for example in my case:

compile 'com.google.android.gms:play-services-plus:6.5.87'
compile 'com.google.android.gms:play-services-location:6.5.87'
compile 'com.google.android.gms:play-services-maps:6.5.87'
compile 'com.google.android.gms:play-services-panorama:6.5.87'

See the list here: http://developer.android.com/google/play-services/setup.html

Now, change the SDK version to 21, and add multiDexEnable on Gradle:

...
compileSdkVersion 21
buildToolsVersion "21.1.2"
...
defaultConfig {
    targetSdkVersion 21        
    multiDexEnabled true
...
}

and Add:

compile 'com.android.support:multidex:1.0.0'

Finally in AndroidManifest.xml add:

<application
    ...
    android:name="android.support.multidex.MultiDexApplication">
    ...
</application>

The documentation about this: http://developer.android.com/tools/building/multidex.html

Upvotes: 7

Related Questions