INSTALL_FAILED_DEXOPT Error in Android 5.0 in Release mode
Asked Answered
M

9

34

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.....

Moton answered 28/9, 2015 at 13:57 Comment(19)
Does your all use and external, pre-built libraries (not game dependencies)? If so, are they in jar or aar form?Gono
Please post the logcat from when the install failsSher
Can you post the build.gradle code? Especially buildTypes element with debug and release variants.Bigeye
@LarrySchiefer we use external jars and Module dependenciesMoton
@AbhishekV please check the question .i have editedMoton
This is a long shot, but once I had similar problems when installing, because I had two accounts on my phone, and somehow the second account (which I never used) had the application installed aswell. So I had to switch accounts, delete it there and than it worked.Murex
just wana ask, are you using google play services lib ?Adallard
@Adallard ..I have google play service library in project....and multidex is enabled...it works for 5 and above devices ..but not certain 5.0 devices.if i change gradle version to 1.0.0..then in debug it works for the above device but release fails...if change 1.3.1 then it does nt for both build variants.Moton
Hey @Rockin, sorry that my answer was not able to help you, try adb uninstall <apk_name> command and tell us what do you get :-)Adallard
after you try to install, can you take logcat and post the logSettler
@Moton - we got this error a long time ago in my previous job. The issue was caused by a bad ProGuard configuration (something releated to the Attributes). Please make absolutely sure you have no "minifyEnabled true" in your project.Harbison
@Harbison I checked all modules and project minifyEnabled is false.Moton
Which is solved this issue for me: Downloaded the 23.0.2 SDK tools: dl.google.com/android/android-sdk_r23.0.2-windows.zip, then I copied only the tools folder to my SDK. Then do the same with the platform tools: dl-ssl.google.com/android/repository/….Vernal
@Zsolt Mester I am using latest sdk tools 24.4Moton
@ZsoltMester I also checked with 23.0.2..Moton
Okay, can you attach a log from logcat?Vernal
@ZsoltMester there is no logcat as application is not installed...you can see the log in console...that already pasted above..Moton
What about the google play services version - is that updated to the latest and you've updated build.gradle with it?Masakomasan
google play services android:versionCode="5077000"Moton
R
4

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.

Ruth answered 7/7, 2016 at 19:55 Comment(0)
G
0

This issue might occur due to mismatching sdks between Android Studio and the Project. The project was using an old sdk and once I made them the same, I cleaned and rebuilt the project and everything was good to go.

Gasolier answered 6/10, 2015 at 10:50 Comment(1)
Hi ,there is no mismatch we give sdk same for all.Moton
A
0

please see if your app has been by mistake installed in your guest account of your phone.

If yes, then un-install or remove it from there.

Do this for all user accounts in your phone.

Additional tips:-

Build -> Clean project Build -> Rebuild project

Adallard answered 7/10, 2015 at 14:14 Comment(6)
You transformed my comment into answer :D well playedMurex
Sorry, i did not see your comment, your comment was hidden. I have faced same problem and answered these type of questions beforeAdallard
@Murex see this link, i have answered these questions before #32910541Adallard
No worries, I tought you missed it. Didn't want to post it as an answer, since it's a long shot. Let's hope it helps :)Murex
@Murex Thanks for understanding :-) kindly see my comments.Adallard
I already mentioned i tried to install the built in a new device bought freshly from market..Clean rebuild all mechanism i have tried...i told you i have googled a lot ..played around for 1 week...atlast only i posted in stack overflowMoton
T
0

This might due to different version of Gradle build tools in your Module and Project build file. Make sure they use the same version in both file, clean and build again, and it should be fine.

Transubstantiation answered 22/10, 2015 at 10:54 Comment(1)
We use only in main project...not in modulesMoton
A
0

It sounds like multidex might be your issue. Android handles this natively on Lollipop devices (which may account for some devices behaving correctly, but others having problems), but uses the multidex library on older devices which could explain why older devices behave uniformly (see http://developer.android.com/tools/building/multidex.html).

Are you close enough to the 65k limit that you could use ProGuard or temporarily remove one of your dependencies such that you wouldn't need multidex? Despite there being a library to support it, it is generally a good idea to reduce your method count so that you don't need it. I know some apps may really need it, but it's worth checking this first.

Also, investigate using the granular Google Play Services modules. If you're pulling in all of GMS, switching to granular includes can reduce your method count significantly: http://android-developers.blogspot.com/2014/12/google-play-services-and-dex-method.html

Amaris answered 17/11, 2015 at 21:38 Comment(0)
A
0

Try to uninstall this app, and all others who have your signature on your device. Clean your project and restart install. Also, you should consider installing your app through another mean that ADB, for instance using dropbox.

Aoudad answered 24/11, 2015 at 11:44 Comment(0)
L
-1

Restarting the emulator from the Android SDK and AVD Manager and selecting the option Wipe User Data has solved this problem for me.

Lubumbashi answered 13/11, 2015 at 14:21 Comment(0)
H
-1

I got the same issue while testing code in my phone. I followed below steps

  1. Clean and Build the code
  2. Upgrade Android Studio to latest release

It solved my issue and please check in your case.

Hairy answered 2/6, 2016 at 17:29 Comment(0)
E
-2

This issues might ocuur when you install the debug/release apk while relese/debug apk is already installed in your device/emulator.means if you are installing debug apk while release apk is exist or if you are installing release apk while debug apk is exist.so uninatall the apk and install it again

Earldom answered 9/11, 2015 at 9:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.