Reputation: 11474
I have below dependencies in my Gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "packagename"
minSdkVersion 10
targetSdkVersion 23
}
sourceSets {
main {
jni.srcDirs = []
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.1'
compile files('libs/FLurry_3.2.2.jar')
compile files('libs/pixel-perfect-collision.jar')
compile files('libs/twitter4j-core-3.0.3.jar')
compile project(':zip_file')
compile project(':andEngine')
compile project(':andEnginePhysicsBox2DExtension')
compile project(':downloader_library')
compile project(':viewPagerLibrary')
compile 'com.google.android.gms:play-services:8.1.0'
compile 'org.apache.commons:commons-lang3:3.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
}
On building gradle file I am getting below error of :
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
To solve this error I have already added multidex dependency :
compile 'com.android.support:multidex:1.0.1'
Still looping around ..
Edited : Already solved problem so do not try to duplicate it and solution is below..!!
Hoping for help.!
Thanks.
Upvotes: 1
Views: 2640
Reputation: 1785
this problem occurs while your whole project have more then 64000
methods.
so you have to add dependency to application build.gradle
file
compile 'com.android.support:multidex:1.0.0'
and then add this tag to AndrodManifest.xml
to application item
<application
...
android:name="android.support.multidex.MultiDexApplication">
If your app uses extends the Application class add this code
@Override
public void attachBaseContext(Context base) {
MultiDex.install(base);
super.attachBaseContext(base);
}
and then next step is to Add multidex support to defaultConfig at build.gradle
defaultConfig {
...
minSdkVersion 16
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
... see http://phpidiots.in/android/unexpected-top-level-exception/
Upvotes: 1
Reputation: 2707
It means your app exceeds 65k method count limit of android app. It seems you are using google play service which is mammoth.
compile 'com.google.android.gms:play-services:8.1.0'
As this document says
You can reduce this by using only the play services you need shown in the same link above. Example if your app only needs gcm you can use its subset like:
com.google.android.gms:play-services-gcm:8.1.0
etc.
Upvotes: 3
Reputation: 47807
You should add
multiDexEnabled true
in build.gradle
defaultConfig {
applicationId 'pkg'
minSdkVersion
targetSdkVersion
versionCode
versionName
// Enable MultiDexing: https://developer.android.com/tools/building/multidex.html
multiDexEnabled true
}
Upvotes: 5