How do I solve the INSTALL_FAILED_DEXOPT error?

AndroidAndroid Install-Apk

Android Problem Overview


I am developing an Android application using Android 2.2, my application APK size is 22.5 MB, and I would like to create a new build for a Samsung tablet. I got the following error:

> INSTALL_FAILED_DEXOPT

How do I solve this kind of error?

Android Solutions


Solution 1 - Android

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

You can find the option as highlighted in the below given image:

Wipe User Data option when starting android emulator

Solution 2 - Android

This seemed to be related to disk space for me. A newly rolled 5.1 emulator boots with a "low on disk space" error - and looking at the emulator properties, the default space allocated for internal storage is 800MB which seems low.

Solution, therefore was to increase this (I went to 4GB). Oddly the emulator still boots with the same disk space warning but factory resetting it (Settings --> Backup and Restore inside the emulator) solved it entirely for me.

Just a bit odd that it doesn't work out of the box with default settings.

Solution 3 - Android

Your old version of the app that you are installing has dependent libraries / jars that have been changed. I ran into this issue when updating other jar files that my app was refrencing.

You will need to Uninstall your old version and then you should have no more issues...

Settings-->Applications-->Manage Applications-->[Find and Uninstall your App]

INSTALL_FAILED_DEXOPT errors should not erupt. Like

[2011-06-14 01:23:40 - ProtectYourself] Installing ProtectYourself.apk...
[2011-06-14 01:24:26 - ProtectYourself] Installation error: INSTALL_FAILED_DEXOPT
[2011-06-14 01:24:26 - ProtectYourself] Please check logcat output for more details.
[2011-06-14 01:24:26 - ProtectYourself] Launch canceled!

Whoo hoo.

Solution 4 - Android

Ran into this with Android Studio 3.4.1 but using an older (5.0) emulator. This procedure (on Mac) fixed the issue:

  1. stop emulator
  2. cd ~/.android/avd/[emulator name].avd
  3. rm *.lock
  4. wipe emulator
  5. start emulator

Solution 5 - Android

If you are using Android Studio, try clean your project:

Build > Clean Project

Solution 6 - Android

It seems like this error message can have many different causes. The case I came across was on a real device (so the emulator bases solutions did not apply).

Basically, when this happens, set your Logcat filter to Verbose or Warn, which will help you get more information about the cause.

In my case, multiple or conflicting versions of JUnit were being included in the project I was working on (a large existing codebase). The Android app I was trying to deploy had several library projects as dependencies, and I had mistakenly set things up to include multiple JUnit jar files.

I discovered this based on a series of Logcat messages. Note that the WARN line gives the cause:

DEBUG/dalvikvm(4808): DexOpt: 'Ljunit/framework/TestSuite$1;' has an earlier definition; blocking out
11-06 14:30:10.973: WARN/dalvikvm(4808): Invalid file flags in class Ljunit/runner/Sorter$Swapper;: 0209
11-06 14:30:10.973: null/libc(4808): Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 4808 (dexopt)

Solution 7 - Android

I' changed the RAM size and internel storage capacity of the emulator Now IT IS Working... in eclipse AVD manager

Solution 8 - Android

try my answer https://stackoverflow.com/a/34918549/3737254

if you use android studio 2.0, DISABLE the instant run.

FYI, instant run is new feature from android studio 2.0 (i never used it >.<)

how to disable : preferences -> build, execution & deployment -> instant run -> disable, then works like magic

Enjoy!

Solution 9 - Android

The only solution that worked for me to fixed this was to increase the VM's RAM to 4GB.

Solution 10 - Android

I needed to disable Instant Run to fix the issue. To disable Instant Run on OS X, go to Android Studio > Preferences > Build, Execution, Deployment > Instant Run then remove the tick from Enable Instant Run to hot swap code/resource changes on deploy (default enabled).

Solution 11 - Android

I had the same issue today with Android Studio on a new virtual device. It appeared I had downloaded the x86_64 image, recreating the VD with the equivalent x86 image fixed it.

I expected to get a INSTALL_FAILED_NO_MATCHING_ABIS in this case but somehow I was stuck with INSTALL_FAILED_DEXOPT

Solution 12 - Android

I am working with Android Studio and had the same error.

Deleting the build folder of the main Modul helped. After deleting everything get back to normal.

Solution 13 - Android

INSTALL_FAIL_DEXOPT usually has to do with the limit placed on classes.dex. On anything pre-ICS dexopt will fail on anything over 5 MB. Recent versions of Android use an 8 or 16 MB buffer.

Check the size of classes.dex in your APK. It would also be good to see what your method count is, as dex has a 65536 method/field limit.


References:

https://stackoverflow.com/questions/14907346/error-while-installing-application-install-failed-dexopt

https://www.facebook.com/notes/facebook-engineering/under-the-hood-dalvik-patch-for-facebook-for-android/10151345597798920

https://stackoverflow.com/questions/15471772/how-to-shrink-code-65k-method-limit-in-dex

Solution 14 - Android

I ran into this problem after enabling the jumboMode flag in the build (dex.force.jumbo=true). Everything worked fine on newer Android devices, but installation failed on Gingerbread.

So if your app requires jumbo mode due to the annoying 65k restriction, try cutting some unused code/strings and setting jumbo mode back to false.

Solution 15 - Android

classes.dex does not make it to the final .apk. Running gradlew --offline clean && gradlew --offline assembleDebug fixed things for me every time. From that point you can start launching the app from Android Studio again.

EDIT: Before what I said above go to Task Manager and kill all cmd.exe and conhost.exe processes (or just the one in which aapt got stuck). Otherwise aapt would crash from now on when launched from command line with the infamous error -1073741819.

Solution 16 - Android

I got the same error and fixed it by increasing the size of internal storage.

The internal storage was initially set to 32MB(I know) and then I installed a couple of apks on it, which had left less space than what was needed for the one to be installed.

Solution 17 - Android

verify the storage space on your device

Solution 18 - Android

a lot of answers here, but maybe it can help someone I had this issue with real device and problem was with D8

try to add this to your gradle.properties and it works for me

android.enableD8=false
android.enableD8.desugaring= false

Solution 19 - Android

I had the app uninstalled and got the INSTALL_FAILED_DEXOPT error nevertheless. If you are working with Android Studio / gradle: gradle clean did the trick for me, Cheers.

Solution 20 - Android

in build.gradle change compiled and build to latest version. and it worked for me.

================

android {
    compileSdkVersion 22
    buildToolsVersion "22"

Solution 21 - Android

I was getting this issue when trying to install on 2.3 devices (fine on 4.0.3). It ended up being due to a lib project i was using had multiple jars which were for stuff already in android e.g. HttpClient and XML parsers etc. Looking at logcat led me to find this as it was telling me it was skipping classes due to them already being present. Nice unhelpful original error there!

Solution 22 - Android

I had this error testing on a real device. Clearing cache/uninstalling, restarting everything didn't work for me, deleting the contents of the build folder did :) (Android studio)

Solution 23 - Android

There's no generic solution, you have to find the error reported on your Logcat to be able to figure it out. Sometimes it's a class that can't be 'dexed' due to an usage of a class not available on the specified Target API for instance. Or it could be a class that you're making reference in your code, but the library that it is in is not being packaged.

Solution 24 - Android

Consider using proguard to shrink your APK. I have the same issue if I try to install a large 25MB+ APK on an old Samsung Galaxy Ace 2.3.6 device without shrinking/optimizing code with proguard.

Jumbo mode and restarting the device is not working.

Solution 25 - Android

In my case, this was a bug in kotlin plugin, version 1.1.51

https://youtrack.jetbrains.com/issue/KT-20034

This error appeared on old devices (API 16).

Fixed this by removing @Parcelize annotations and replacing them with this code generator: https://github.com/nekocode/android-parcelable-intellij-plugin-kotlin

Solution 26 - Android

I found there's one reason for this problem: not enough space on mobile. So I delete several APP from mobile and it's fixed.

Solution 27 - Android

targetSdkVersion 22//17==========================> set this number less then or equal to the version of Android OS on devices might help

 defaultConfig {
        applicationId "software.nhut.personalutilitiesforlife"
        minSdkVersion 16
        targetSdkVersion 22//17==========================> set this number less then or equal to the version of Android OS on devices might help
        versionCode 5
        versionName "1.26"
        // Enabling multidex support.
        multiDexEnabled true
    }

Solution 28 - Android

In my case problem was happening on some devices running API 21 and 22. Setting android:vmSafeMode="true" in manifest under application tag resolved the issue. However, it is not recommended for release builds, so I created two xml files in values folder. The default one for older API's:

<resources>
    <bool name="vm_safe_mode">true</bool>
</resources>

And the same for API's >= 23 with false value. In that case devices with newer OS won't be affected and the old ones will at least work.

Solution 29 - Android

I had this problem when there were some Unicode characters in my method names (due to, of all things, copy/pasting from a powerpoint file) that Dalvik did not like. You can see this by looking at Logcat output while trying to install the APK.

This was on a real device.

Solution 30 - Android

Solved by correcting date time on the phone (it was some default date 01.01.1980), and cleaning the project.

Solution 31 - Android

I had changed my version of android version 4 support for sdk 21 and had this error. So I went back the version of support for the old version (before 21) and it worked. The error was occurring only in android 2.3

Solution 32 - Android

I've ran into this problem when I was trying to update new build tools 24.0.1. Internet connection was lost and tools was not downloaded successfully, after that I got this error and spent a lot of time trying to solve it. But when I succesfully updated build tools - problem solved. Good luck.

Solution 33 - Android

Make sure you have all the SDK's you need installed and Gradle is targeting the right version.

I was having the same issue, but it was caused by me updating my device to Android 5.0 and then forgetting to change all my builds to target it.

Solution 34 - Android

I have faced this issue because there was some mismatch with the libraries i was using

Resolved by updaing android sdk to latest. Check SDK manager if it shows update then fully update, clean your project and then run, it will work :)

Solution 35 - Android

Maybe this will help:

  1. Wipe the user data before launching the emulator
  2. clean the project
  3. remove dependencies which are not required....

Solution 36 - Android

The error get resolved by deleting the build folder of your main app.It will recreate again.

Solution 37 - Android

In android Studio click on File -> Invalidate caches/ restart . This did the trick for me when I was getting this error when I got this error on device not emulator.

Solution 38 - Android

For me it was proguard that was causing INSTALL_FAILED_DEXOPT on some Samsung devices with Android 5.x.

Namely I had to add this to proguard - not sure why it helped.

-keepattributes LocalVariableTable

Solution 39 - Android

Restart your device.

In my case, the app run in most devices except for one: a cellphone that was too old and had been failing lately, the app thrown this error even without having installed the app once.

Solution 40 - Android

Also if you are using ECLIPSE yet, try clean your project:

Project > Clean...

Solution 41 - Android

One reason is that classes.dex is not found in the root of the .apk-package. Either

  • this file is missing in the apk-package or
  • it is located in a subfolder within the .apk file.

Both situations cause the termination because Android supposedly searches only in the root of the apk file. The confusion is because the build run of the .apk file was without an error message.

Core reasons for that error may be:

  • The dx tool need classes.dex in the current main working folder. But in reality classes.dex is located somewhere other.
  • aapt have a wrong information for the location for classes.dex. For example with aapt.exe add ... bin/classes.dex. Thats would be wrong because classes.dex is in a subfolder /bin of the created .apk file.

Solution 42 - Android

To anyone searching for this with keyword "Room". I met this problem while implementing Room to manage my database. The cause was that I copied all dependencies from Android documentation. Copy only the ones you need. If you are not using Kotlin nor Guava add only:

implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
testImplementation "androidx.room:room-testing:$room_version"

Solution 43 - Android

As this seems to be a problem I have myself encountered multiple times and this time none of the shared solutions helped me, I'll still post what helped me personally and what I believe may help someone else in future:

Go to your project's directory and find build/intermediates/dex-cache/cache file. Remove it - as name suggests, it's a cached dex file that may be outdated if you have made changes to your project's dependencies, build tools version etc.

Solution 44 - Android

If you have error INSTALL_FAIL_DEXOPT, see in manifest android:targetSdkVersion. Set version < 21 sample: > android:targetSdkVersion="19"

This worked for me.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjohnView Question on Stackoverflow
Solution 1 - AndroidVikas PatidarView Answer on Stackoverflow
Solution 2 - AndroidHughHughTeotlView Answer on Stackoverflow
Solution 3 - AndroidLenn DollingView Answer on Stackoverflow
Solution 4 - AndroidKenView Answer on Stackoverflow
Solution 5 - AndroidSandroMarquesView Answer on Stackoverflow
Solution 6 - AndroidwsanvilleView Answer on Stackoverflow
Solution 7 - AndroidKATJ SrinathView Answer on Stackoverflow
Solution 8 - AndroidyfsxView Answer on Stackoverflow
Solution 9 - AndroidJimView Answer on Stackoverflow
Solution 10 - AndroidiamkaanView Answer on Stackoverflow
Solution 11 - AndroiddvkchView Answer on Stackoverflow
Solution 12 - AndroidInformatic0reView Answer on Stackoverflow
Solution 13 - AndroidJared RummlerView Answer on Stackoverflow
Solution 14 - AndroidfriederbluemleView Answer on Stackoverflow
Solution 15 - AndroidEugen PechanecView Answer on Stackoverflow
Solution 16 - AndroidbinRAINView Answer on Stackoverflow
Solution 17 - AndroidFarido mastrView Answer on Stackoverflow
Solution 18 - AndroidNataTseView Answer on Stackoverflow
Solution 19 - AndroidJacksOnF1reView Answer on Stackoverflow
Solution 20 - AndroidriseresView Answer on Stackoverflow
Solution 21 - AndroidDoriView Answer on Stackoverflow
Solution 22 - AndroidGyroscopeView Answer on Stackoverflow
Solution 23 - AndroidAlécio CarvalhoView Answer on Stackoverflow
Solution 24 - AndroidslottView Answer on Stackoverflow
Solution 25 - AndroidstillwaitingView Answer on Stackoverflow
Solution 26 - AndroidJalon RayView Answer on Stackoverflow
Solution 27 - AndroidThunder knightView Answer on Stackoverflow
Solution 28 - AndroidanroView Answer on Stackoverflow
Solution 29 - AndroidthoutbeckersView Answer on Stackoverflow
Solution 30 - AndroidNo NameView Answer on Stackoverflow
Solution 31 - AndroidCícero MouraView Answer on Stackoverflow
Solution 32 - AndroidAlex PerevozchykovView Answer on Stackoverflow
Solution 33 - Androiduser4474925View Answer on Stackoverflow
Solution 34 - AndroidSonali8890View Answer on Stackoverflow
Solution 35 - AndroidRajat SawantView Answer on Stackoverflow
Solution 36 - AndroidPrateekView Answer on Stackoverflow
Solution 37 - AndroidAmro elaswarView Answer on Stackoverflow
Solution 38 - AndroidMartin RajniakView Answer on Stackoverflow
Solution 39 - AndroiddianakarenmsView Answer on Stackoverflow
Solution 40 - AndroidAdamzView Answer on Stackoverflow
Solution 41 - AndroidgotwoView Answer on Stackoverflow
Solution 42 - AndroidKrzysztof WiśniewskiView Answer on Stackoverflow
Solution 43 - AndroidSosoelView Answer on Stackoverflow
Solution 44 - Androiduser3270024View Answer on Stackoverflow