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.