Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INSTALL_FAILED_DEXOPT Error in Android 5.0 in Release mode

I have a strange issue with INSTALL_FAILED_DEXOPT . This occurs in android 5.0 devices in emulator as well as in devices. And strange thing is that it works well when build variant in Debug mode .

If I change to Release I get this exception only on 5.0 devices. I have thoroughly went through all the links that is available in google.

  1. Wipe the data

  2. Bought a new device where I can install for the first time but still I face the same issue.

  3. Project has multidex support:- true in gradle

  4. Also tried change SDK tool version and build tool version to latest which is 24.4.0.

I use this device enter image description here

When i build in release mode i get this Error enter image description here

in Console

enter image description here

These are the build type we use.

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        signingConfig signingConfigs.release
    }


    debug {
        applicationIdSuffix ".debug"
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        signingConfig signingConfigs.debug
    }


}

Image of SDK Tools used:

enter image description here I can assure you that there has been never a build installed the device.I have cleared everything if it already installed.

Can somebody in this world could help me with this issue.Because it driving us crazy.....

like image 453
Rockin Avatar asked Sep 28 '15 13:09

Rockin


1 Answers

When the APK is installed onto Android, the OS executes dex2opt for optimizing. The INSTALL_FAILED_DEXOPT error message means that your device can't optimize the dex file.

This issue usually occurs because of the dex file size. Usually, you can find a LinearAlloc Limit warning or error message in the Android monitor when this happens. If it is a problem of dex size, add this to your build.gradle file:

afterEvaluate {
    tasks.matching {
        it.name.startsWith('dex')
    }.each { dx ->
        if (dx.additionalParameters == null) {
            dx.additionalParameters = []
        }
     
         // To avoid linearAlloc limit problem on Gingerbread and below
         dx.additionalParameters += "--set-max-idx-number=50000"
         dx.additionalParameters += "--minimal-main-dex"
    }
}

Also, be sure to turn Instant Run off.

like image 72
hanbumpark Avatar answered Oct 18 '22 14:10

hanbumpark