INSTALL_FAILED_DEXOPT: Can't install app on Android Emulator

I started getting the INSTALL_FAILED_DEXOPT error when trying to install my app on a emulator.
My machine is: Mac
My Appium version is: 1.8.1
My Emulator is: 5.1 Google Api(22)

I already did Wipe the data and even delete all my emulators directly from the folder - that didn’t help. I am still able to install the app on a physical device. Any help is appreciated. Thank you!

DB] Install command stdout: [ 1%] /data/local/tmp/appium-app.apk [ADB] [ 2%] /data/local/tmp/appium-app.apk [ADB] [ 3%] /data/local/tmp/appium-app.apk [ADB] [ 4%] /data/local/tmp/appium-app.ap…-fyujuc.k331r/appium-app.apk: 1 file pushed. 82.1 MB/s (5633009 bytes in 0.065s) [ADB] pkg: /data/local/tmp/appium-app.apk [ADB] Failure [INSTALL_FAILED_DEXOPT] [AndroidDriver] Shutting down Android driver [AndroidDriver] Called deleteSession but bootstrap wasn’t active [Logcat] Stopping logcat capture [ADB] Running ‘/Users/dimitardimitrov/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop io.appium.unlock’ [AndroidDriver] Not cleaning generated files. Add clearSystemFiles capability if wanted. [BaseDriver] Event ‘newSessionStarted’ logged at 1539946795554 (13:59:55 GMT+0300 (EEST))

[MJSONWP] [100%] /data/local/tmp/appium-app.apk [MJSONWP] /var/folders/sn/27wtp9n92mv9wvcfhmwzt7040000gt/T/2018919-17680-fyujuc.k331r/appium-app.apk: 1 file pushed. 82.1 MB/s (5633009 bytes in 0.065s) [MJSONWP] pkg: /data/local/tmp/appium-app.apk [MJSONWP] Failure [INSTALL_FAILED_DEXOPT] [MJSONWP] at ADB.executeInstall$ (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/lib/tools/apk-utils.js:398:13) [MJSONWP] at tryCatch (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40) [MJSONWP] at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22) [MJSONWP] at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21) [MJSONWP] at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37) [MJSONWP] at [HTTP] <-- POST /wd/hub/session 500 9778 ms - 3707

Even when I try with adb directly it won’t work:
➜ Desktop adb install app_xxx.apk
app_xxx.apk: 1 file pushed. 39.3 MB/s (6457649 bytes in 0.157s)
pkg: /data/local/tmp/app_xxx.apk
Failure [INSTALL_FAILED_DEXOPT]

That’s interesting. I’ve seen the stackoverflow link you provided. I did try yesterday everything there and it didn’t help. What I just did to fix my issue was:

  1. Navigate to the /Users/user_xxx/.android/avd/Nexus6API22.avd
  2. Delete all the locks via: $rm *.lock
  3. Wiped Data via AVD Manager
  4. Restart the Emulator
  5. Success.

Thanks!