I am using Android Studio to develop this app, and today when I tried to upload it to my device to test I got a popup window saying:
Installation fail
When your dex file gets larger then buffer size( i.e. contains more than 65k methods) then this error occurs. You can avoid this error in two ways: 1.) Remove unused code with ProGuard - Configure the ProGuard settings for your app to run ProGuard and ensure you have shrinking enabled for release builds. Enabling shrinking ensures you are not shipping unused code with your APKs.
2.) You can configure your app for multidex support. Refer this link to use it: https://developer.android.com/tools/building/multidex.html
For multidex support I override this method in my application class:
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
and modify my build.gradle like this:
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
minSdkVersion 14 //lower than 14 doesn't support multidex
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Hope it helps!
EDITS: Took out the text explanation from the code.
I have Faced this problem today, Got the solution. Saw how much space the emulator and was almost nothing so I deleted some apps and my problem was resolved.Thanks
I found out my problem was caused by old SDK Build Tools version, which was causing the Clean to fail. I upgraded my SDK Build Tools to the newest version and after that cleaning worked, and I no longer received the stale dexed jars error. Hopefully this will help someone else struggling with this issue.
In my case it was caused by a file named "dictionary.txt". I just deleted it and solved the problem.