APK won't install: DalvikVM cannot optimize it (Byte swap and verify fails)
I'm getting an INSTALL_FAILED_DEXOPT error (which doesn't seem to have anything to do with the other questions that have been asked here about INSTALL_FAILED_DEXOPT) when I try to install my Android app under the following conditions:
- First the app is installed to a freshly created 2.3.3 emulator using Eclipse and the Android plugin.
- A newer version of the app is installed over previous version on prexisting 2.3.3 and 2.2 emulators using Eclipse as above.
- I have even tried clicking the "Wipe User Data" checkbox when starting the emulators.
- A newer version of the app is installed over previous version on HTC G2 running CyanogenMod 7.1 nightly (2.3.5).
- Removed previous version of the app from G2 using "adb -d uninstall com.jackcholt.reveal" then tried to install the new version on G2 using "adb -d install Reveal3.apk"
Every time I have tried I have received the following errors in LogCat:
D/PackageParser( 75): Scanning package: /data/app/vmdl352595685.tmp
D/PackageManager( 75): Scanning package com.jackcholt.reveal
I/PackageManager( 75): Unpacking native libraries for /data/app/com.jackcholt.reveal-1.apk
D/installd( 35): DexInv: --- BEGIN '/data/app/com.jackcholt.reveal-1.apk' ---
E/dalvikvm( 378): Invalid name: 'menu_item_reindex'
E/dalvikvm( 378): Trouble with item 282 @ offset 0x17dd8
E/dalvikvm( 378): Cross-item verify of section type 0004 failed
E/dalvikvm( 378): ERROR: Byte swap + verify failed
E/dalvikvm( 378): Optimization failed
W/installd( 35): DexInv: --- END '/data/app/com.jackcholt.reveal-1.apk' --- status=0xff00, process failed
E/installd( 35): dexopt failed on '/data/dalvik-cache/data@app@com.jackcholt.reveal-1.apk@classes.dex' res = 65280
W/PackageManager( 75): Package couldn't be installed in /data/app/com.jackcholt.reveal-1.apk
And the first thing I tried was changing the "Invalid Name" -- 'menu_item_index'. It is found toward the end in a menu definition XML file with the following content:
<?xml version="1.0" encoding="utf-8"?>
<menu android:id="@+id/shared_menu" xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:icon="@android:drawable/ic_menu_recent_history"
android:title="@string/menu_history"
android:id="@+id/menu_item_history"/>
<item android:icon="@android:drawable/ic_input_get"
android:title="@string/menu_bookmark"
android:id="@+id/menu_item_bookmark"/>
<item android:id="@+id/menu_item_previous"
android:icon="@drawable/previous_chapter"
android:title="@string/menu_previous"/>
<item android:id="@+id/menu_item_next"
android:icon="@drawable/next_chapter"
android:title="@string/menu_next"/>
<item android:icon="@android:drawable/ic_menu_set_as"
android:id="@+id/menu_item_download"
android:title="@string/menu_browser"/>
<item android:icon="@android:drawable/ic_menu_preferences"
android:id="@+id/menu_item_settings"
android:title="@string/menu_settings"/>
<item android:id="@+id/menu_item_note_browser"
android:title="@string/annot_br开发者_JAVA技巧ow"
android:icon="@android:drawable/ic_input_get"/>
<item android:icon="@android:drawable/ic_menu_more"
android:title="@string/more"
android:id="@+id/menu_extra">
<menu>
<item android:id="@+id/menu_item_download"
android:title="@string/menu_browser"/>
<item android:id="@+id/menu_item_note_browser"
android:title="@string/annot_brow"/>
<item android:title="@string/menu_help"
android:id="@+id/menu_item_help"/>
<item android:title="@string/menu_refresh_library"
android:id="@+id/menu_item_refresh_lib"/>
<item android:title="@string/menu_update"
android:id="@+id/menu_item_update"/>
<item android:title="@string/reset"
android:id="@+id/menu_item_reset"/>
<item android:title="@string/donate_menu"
android:id="@+id/menu_item_donate"/>
<item android:title="@string/menu_license"
android:id="@+id/menu_item_license"/>
<item android:id="@+id/menu_item_about"
android:title="@string/menu_about"/>
<item android:id="@+id/menu_item_reindex"
android:title="@string/reindex_books"/>
</menu>
</item>
</menu>
What do I need to do to avoid the INSTALL_FAILED_DEXOPT error?
Not sure if this is related but could this be caused by a dex output file that is too large for the version of android you are running on?
ie, does the same binary work on a higher API version of android? (if yes, then it's likely caused by too many methods problem)
there are are loads of other threads around dexopt failures, it seems like the only accepted answer for this is to limit the number of classes you are using; are you using proguard?
精彩评论