2015-02-02 21 views
8

nie wdrażać nowe bibliotekami, ale problem ten wystąpił podczas kodowania:Weird: nieoczekiwany wyjątek najwyższego poziomu: Wykonanie nie powiodło się dla aplikacji zadanie: dexDebug

Błąd: Wykonanie nie powiodło się dla zadania „: app: dexDebug”.

com.android.ide.common.internal.LoggedErrorException: Failed to run command: C:\android-sdk\build-tools\21.1.1\dx.bat --dex --no-optimize --output F:\Android_Donbas\ReDonbasIDEANew\app\build\intermediates\dex\debug --input-list=F:\Android_Donbas\ReDonbasIDEANew\app\build\intermediates\tmp\dex\debug\inputList.txt Error Code: 2 Output: UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:502) at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:277) at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:491) at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:168) 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:302) at com.android.dx.command.dexer.Main.run(Main.java:245) at com.android.dx.command.dexer.Main.main(Main.java:214) at com.android.dx.command.Main.main(Main.java:106)

mój build.gradle:

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile 'com.android.support:support-v4:21.0.3' 
    compile 'com.google.android.gms:play-services:6.5.87' 
    compile 'com.google.code.gson:gson:2.3' 
    compile 'com.google.code.gson:gson:2.3' 
    compile 'com.google.code.gson:gson:2.2.2' 
    compile 'com.google.guava:guava:18.0' 
    compile 'com.android.support:appcompat-v7:20.0.0' 
    compile files('libs/android-async-http-1.4.6.jar') 
    compile files('libs/AndroidSwipeLayout-v1.1.6.jar') 
    compile files('libs/apache-mime4j-0.5.jar') 
    compile files('libs/crashlytics.jar') 
    compile files('libs/httpclient-4.2.1.jar') 
    compile files('libs/httpcore-4.2.1.jar') 
    compile files('libs/httpmime-4.2.1.jar') 
    compile files('libs/nineoldandroids-2.4.0.jar') 
    compile files('libs/ormlite-android-4.48.jar') 
    compile files('libs/ormlite-core-4.48.jar') 
    compile files('libs/ormlite-jdbc-4.48.jar') 
    compile files('libs/osmdroid-android-4.2.jar') 
    compile files('libs/slf4j-android-1.6.1-RC1.jar') 
    compile files('libs/universal-image-loader-1.9.3.jar') 
} 



packagingOptions { 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.t' 
    } 

Odpowiedz

9

Mogłeś trafić limit 65k metod. Aby korzystać z Usług Google Play z większą ziarnistością, postępuj zgodnie z this guide, możesz używać tylko tych części, które chcesz. To prawdopodobnie naprawi twój problem.

+1

Tak, problem występował w limicie 65 KB. –

+1

Oficjalna dokumentacja dla tego: https://developers.google.com/android/guides/setup#split – mattm

2

Dodajesz multiDexEnabled prawdziwe w defaultConfig w build.gradle rozwiązać mój problem

defaultConfig { 
     applicationId "com.example.project" 
     minSdkVersion 15 
     targetSdkVersion 21 
     versionCode 1 
     versionName "1.0.0" 
     multiDexEnabled true 
    } 
0

mi rozwiązać mój problem z dodaniem tych w kompilacji Gradle:

defaultConfig { 
     multiDexEnabled true 


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

Innym rozwiązaniem może być usunięcie niepotrzebnych bibliotek

Powiązane problemy