问题
I get the warning mentioned above (in addition to other similar warnings), followed by an error:
java.lang.NoClassDefFoundError: com.android.vending.expansion.downloader.R$string
I get this error right after running the 2nd line here: (I'm using the Apk expansion, downloader, zip, and Licensing libraries)
public void onServiceConnected(Messenger m) {
Log.i("Main Activity - APK Downloader", "SERVICE CONNECTED!!!");
mRemoteService = DownloaderServiceMarshaller.CreateProxy(m); // ERROR!
mRemoteService.onClientUpdated(mDownloaderClientStub.getMessenger());
}
Extract from my LOG:
07-20 11:31:16.371: I/dalvikvm(752): Could not find method android.os.Bundle.getString, referenced from method com.android.vending.expansion.zipfile.APEZProvider.initIfNecessary
07-20 11:31:16.371: W/dalvikvm(752): VFY: unable to resolve virtual method 340: Landroid/os/Bundle;.getString (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
07-20 11:31:16.371: D/dalvikvm(752): VFY: replacing opcode 0x6e at 0x003e
07-20 11:31:16.381: D/dalvikvm(752): VFY: dead code 0x0041-005c in Lcom/android/vending/expansion/zipfile/APEZProvider;.initIfNecessary ()Z
07-20 11:31:16.381: D/dalvikvm(752): VFY: dead code 0x0070-0076 in Lcom/android/vending/expansion/zipfile/APEZProvider;.initIfNecessary ()Z
07-20 11:31:16.582: D/dalvikvm(752): GC_EXTERNAL_ALLOC freed 75K, 48% free 2819K/5379K, external 1625K/2137K, paused 50ms
07-20 11:31:16.931: D/szipinf(752): Initializing inflate state
07-20 11:31:17.421: D/dalvikvm(752): GC_EXTERNAL_ALLOC freed 9K, 48% free 2830K/5379K, external 7801K/7819K, paused 47ms
07-20 11:31:21.091: W/dalvikvm(752): VFY: unable to resolve static field 65 (state_unknown) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.091: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0003
07-20 11:31:21.101: W/dalvikvm(752): VFY: unable to resolve static field 57 (state_idle) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.101: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0006
07-20 11:31:21.111: W/dalvikvm(752): VFY: unable to resolve static field 56 (state_fetching_url) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.111: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0009
07-20 11:31:21.121: W/dalvikvm(752): VFY: unable to resolve static field 50 (state_connecting) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.121: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x000c
07-20 11:31:21.131: W/dalvikvm(752): VFY: unable to resolve static field 51 (state_downloading) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.131: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x000f
07-20 11:31:21.142: W/dalvikvm(752): VFY: unable to resolve static field 49 (state_completed) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.142: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0012
07-20 11:31:21.161: W/dalvikvm(752): VFY: unable to resolve static field 60 (state_paused_network_unavailable) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.161: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0015
07-20 11:31:21.161: W/dalvikvm(752): VFY: unable to resolve static field 58 (state_paused_by_request) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.161: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0018
07-20 11:31:21.171: W/dalvikvm(752): VFY: unable to resolve static field 63 (state_paused_wifi_disabled) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.171: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x001b
07-20 11:31:21.181: W/dalvikvm(752): VFY: unable to resolve static field 64 (state_paused_wifi_unavailable) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.181: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x001e
07-20 11:31:21.201: W/dalvikvm(752): VFY: unable to resolve static field 63 (state_paused_wifi_disabled) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.201: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0021
07-20 11:31:21.210: W/dalvikvm(752): VFY: unable to resolve static field 64 (state_paused_wifi_unavailable) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.210: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0024
07-20 11:31:21.210: W/dalvikvm(752): VFY: unable to resolve static field 61 (state_paused_roaming) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.210: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0027
07-20 11:31:21.221: W/dalvikvm(752): VFY: unable to resolve static field 59 (state_paused_network_setup_failure) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.221: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x002a
07-20 11:31:21.231: W/dalvikvm(752): VFY: unable to resolve static field 62 (state_paused_sdcard_unavailable) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.231: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x002d
07-20 11:31:21.251: W/dalvikvm(752): VFY: unable to resolve static field 55 (state_failed_unlicensed) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.251: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0030
07-20 11:31:21.262: W/dalvikvm(752): VFY: unable to resolve static field 53 (state_failed_fetching_url) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.262: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0033
07-20 11:31:21.281: W/dalvikvm(752): VFY: unable to resolve static field 54 (state_failed_sdcard_full) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.281: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0036
07-20 11:31:21.291: W/dalvikvm(752): VFY: unable to resolve static field 52 (state_failed_cancelled) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:21.291: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0039
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x0005-0005 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x0008-0008 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x000b-000b in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x000e-000e in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x0011-0011 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x0014-0014 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x0017-0017 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x001a-001a in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x001d-001d in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x0020-0020 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x0023-0023 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x0026-0026 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.291: D/dalvikvm(752): VFY: dead code 0x0029-0029 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.301: D/dalvikvm(752): VFY: dead code 0x002c-002c in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.301: D/dalvikvm(752): VFY: dead code 0x002f-002f in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.301: D/dalvikvm(752): VFY: dead code 0x0032-0032 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.301: D/dalvikvm(752): VFY: dead code 0x0035-0035 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.301: D/dalvikvm(752): VFY: dead code 0x0038-0038 in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:21.301: D/dalvikvm(752): VFY: dead code 0x003b-003b in Lcom/google/android/vending/expansion/downloader/Helpers;.getDownloaderStringResourceIDFromState (I)I
07-20 11:31:23.101: W/dalvikvm(752): VFY: unable to resolve static field 65 (state_unknown) in Lcom/android/vending/expansion/downloader/R$string;
07-20 11:31:23.101: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0079
07-20 11:31:23.121: D/dalvikvm(752): VFY: dead code 0x007b-007c in Lcom/google/android/vending/expansion/downloader/impl/DownloadNotification;.onDownloadStateChanged (I)V
07-20 11:31:23.141: W/dalvikvm(752): VFY: unable to resolve static field 48 (status_bar_ongoing_event_progress_bar) in Lcom/android/vending/expansion/downloader/R$layout;
07-20 11:31:23.141: D/dalvikvm(752): VFY: replacing opcode 0x60 at 0x0022
07-20 11:31:23.141: D/dalvikvm(752): VFY: dead code 0x0024-0091 in Lcom/google/android/vending/expansion/downloader/impl/V3CustomNotification;.updateNotification (Landroid/content/Context;)Landroid/app/Notification;
07-20 11:31:23.180: D/LVLDL(752): Service Bound
07-20 11:31:31.831: I/Main Activity - APK Downloader(752): SERVICE CONNECTED!!!
07-20 11:32:09.906: D/AndroidRuntime(752): Shutting down VM
07-20 11:32:09.906: W/dalvikvm(752): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-20 11:32:09.992: E/AndroidRuntime(752): FATAL EXCEPTION: main
07-20 11:32:09.992: E/AndroidRuntime(752): java.lang.NoClassDefFoundError: com.android.vending.expansion.downloader.R$string
07-20 11:32:09.992: E/AndroidRuntime(752): at com.google.android.vending.expansion.downloader.Helpers.getDownloaderStringResourceIDFromState(Helpers.java:268)
07-20 11:32:09.992: E/AndroidRuntime(752): at com.google.android.vending.expansion.downloader.impl.DownloadNotification.onDownloadStateChanged(DownloadNotification.java:106)
07-20 11:32:09.992: E/AndroidRuntime(752): at com.google.android.vending.expansion.downloader.impl.DownloaderService$LVLRunnable.run(DownloaderService.java:752)
07-20 11:32:09.992: E/AndroidRuntime(752): at android.os.Handler.handleCallback(Handler.java:587)
07-20 11:32:09.992: E/AndroidRuntime(752): at android.os.Handler.dispatchMessage(Handler.java:92)
07-20 11:32:09.992: E/AndroidRuntime(752): at android.os.Looper.loop(Looper.java:130)
07-20 11:32:09.992: E/AndroidRuntime(752): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-20 11:32:09.992: E/AndroidRuntime(752): at java.lang.reflect.Method.invokeNative(Native Method)
07-20 11:32:09.992: E/AndroidRuntime(752): at java.lang.reflect.Method.invoke(Method.java:507)
07-20 11:32:09.992: E/AndroidRuntime(752): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-20 11:32:09.992: E/AndroidRuntime(752): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-20 11:32:09.992: E/AndroidRuntime(752): at dalvik.system.NativeStart.main(Native Method)
回答1:
The initIfNecessary()
in APEZProvider Class uses a version of getString [getString (String key, String defaultValue)]
which is available only in API 12 and above. Try to run your app on API 12 or higher and you might not get this error. The way I solved this error for use on lower API is to replace the function with getString (String key) which returns a null if key is not found and check for null instead of defaultValue.
来源:https://stackoverflow.com/questions/11639988/android-unable-to-resolve-static-field-65-state-unknown-in-lcom-android-vendi