UNCERTAIN TOP-LEVEL EXCLUSION: dependency merge com.android.dex.DexIndexOverflowException

there is a problem in my project when I want to add a google dependency to a google map in my application. the problem is when I want to run the project, I give these errors:

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:283)
    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: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_72\bin\java.exe'' finished with non-zero exit value 2

and these are my dependencies:

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        minSdkVersion 14
        versionCode 2
        versionName "1.0.1"
    }
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:support-v13:22.0.0'
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.android.support:support-v4:22.0.0'
    compile 'com.google.android.gms:play-services:8.1.0'
    compile ('org.bouncycastle:bcprov-jdk16:1.46')
    compile ('com.nineoldandroids:library:2.4.0')
    compile ('commons-lang:commons-lang:2.6')
    compile ('com.google.zxing:core:3.2.0')
}

I also delete all libraries, because I may have problems with google play 8.1.0, but nothing has changed. I also tried to exclude com.google.android.gms:play-servicescompilation from all, but this did not work either.

+4
source share
2 answers

, .
.

.

dependencies{
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:support-v13:22.0.0'   ARE YOU SURE?
    compile 'com.android.support:appcompat-v7:22.0.0'  TWICE ? REMOVE IT
    compile 'com.android.support:support-v4:22.0.0'    APPCOMPAT contains it. REMOVE IT.
}

, . 65536 dex.

-:
com.android.dex.DexIndexOverflowException: [0, 0xffff]: 65536

gradle 0.14.0 Build Tools 21.1.0 multidex.

build.gradle:

android {

    defaultConfig {
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }
    ...
}

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

Manifest MultiDexApplication multidex

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.multidex.myapplication">
    <application
        ...
        android:name="android.support.multidex.MultiDexApplication">
        ...
    </application>
</manifest>

Application, Application MultiDexApplication.

+2

.. {

compile fileTree (dir: 'libs', include: ['*.jar'])

**compile 'com.android.support:appcompat-v7:22.2.0'**
compile 'com.android.support:support-v13:22.0.0'
**compile 'com.android.support:appcompat-v7:22.0.0'**
compile 'com.android.support:support-v4:22.0.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile ('org.bouncycastle:bcprov-jdk16:1.46')
compile ('com.nineoldandroids:library:2.4.0')
compile ('commons-lang:commons-lang:2.6')
compile ('com.google.zxing:core:3.2.0')

}

2 , . 'com.android.support:appcompat-v7:22.0.0' compile 'com.android.support:appcompat-v7:22.2.0' , .

"libs". . , .

+1

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


All Articles