Android Studio で java.lang.VerifyError にはまった話
TIME:966 591-591/com.example.mofootter E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.VerifyError: com/example/mofootter/MainActivity at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1319) at android.app.Instrumentation.newActivity(Instrumentation.java:1023) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) at android.app.ActivityThread.access$600(ActivityThread.java:123) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4424) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) |
Android Studio で開発していて、 java.lang.VerifyError ではまってしまったので。解決方法のメモ。
まず、この例外が発生するのは、SDKのバージョン違いなどって言われているけど、エミュレータのハードウェア構成上の不具合でも発生するらしい。
これを、解決するには、例外が出た少し上のところをたどってみる
TIME:378 93-107/system_process I/Process﹕ Sending signal. PID: 591 SIG: 3 TIME:378 591-596/com.example.mofootter I/dalvikvm﹕ threadid=3: reacting to signal 3 TIME:517 591-591/com.example.mofootter I/System.out﹕ waiting for debugger to settle... TIME:527 591-596/com.example.mofootter I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' TIME:597 93-107/system_process I/Process﹕ Sending signal. PID: 591 SIG: 3 TIME:607 591-596/com.example.mofootter I/dalvikvm﹕ threadid=3: reacting to signal 3 TIME:746 591-591/com.example.mofootter I/System.out﹕ waiting for debugger to settle... TIME:746 591-596/com.example.mofootter I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' TIME:946 591-591/com.example.mofootter I/System.out﹕ waiting for debugger to settle... TIME:147 591-591/com.example.mofootter I/System.out﹕ waiting for debugger to settle... TIME:355 591-591/com.example.mofootter I/System.out﹕ waiting for debugger to settle... TIME:366 93-107/system_process I/Process﹕ Sending signal. PID: 591 SIG: 3 TIME:376 591-596/com.example.mofootter I/dalvikvm﹕ threadid=3: reacting to signal 3 TIME:387 591-596/com.example.mofootter I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' TIME:427 37-37/? D/dalvikvm﹕ GC_EXPLICIT freed <1K, 4% free 9032K/9347K, paused 63ms+146ms TIME:557 591-591/com.example.mofootter I/System.out﹕ waiting for debugger to settle... TIME:706 93-107/system_process I/Process﹕ Sending signal. PID: 591 SIG: 3 TIME:756 591-591/com.example.mofootter I/System.out﹕ waiting for debugger to settle... TIME:756 591-596/com.example.mofootter I/dalvikvm﹕ threadid=3: reacting to signal 3 TIME:847 591-596/com.example.mofootter I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' TIME:956 591-591/com.example.mofootter I/System.out﹕ debugger has settled (1429) TIME:206 93-107/system_process I/Process﹕ Sending signal. PID: 591 SIG: 3 TIME:206 591-596/com.example.mofootter I/dalvikvm﹕ threadid=3: reacting to signal 3 TIME:277 591-596/com.example.mofootter I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' TIME:706 93-107/system_process I/Process﹕ Sending signal. PID: 591 SIG: 3 TIME:706 591-596/com.example.mofootter I/dalvikvm﹕ threadid=3: reacting to signal 3 TIME:776 591-596/com.example.mofootter I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' TIME:867 591-591/com.example.mofootter W/dalvikvm﹕ VFY: unable to resolve exception class 121 (Landroid/os/OperationCanceledException;) TIME:867 591-591/com.example.mofootter W/dalvikvm﹕ VFY: unable to find exception handler at addr 0x7c TIME:877 591-591/com.example.mofootter W/dalvikvm﹕ VFY: rejected Lcom/example/mofootter/MainActivity;.loadimg ()V TIME:877 591-591/com.example.mofootter W/dalvikvm﹕ VFY: rejecting opcode 0x0d at 0x007c TIME:877 591-591/com.example.mofootter W/dalvikvm﹕ VFY: rejected Lcom/example/mofootter/MainActivity;.loadimg ()V TIME:887 591-591/com.example.mofootter W/dalvikvm﹕ Verifier rejected class Lcom/example/mofootter/MainActivity; TIME:887 591-591/com.example.mofootter W/dalvikvm﹕ Class init failed in newInstance call (Lcom/example/mofootter/MainActivity;) TIME:897 591-591/com.example.mofootter D/AndroidRuntime﹕ Shutting down VM TIME:897 591-591/com.example.mofootter W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x409c01f8) |
赤字で書いた場所にヒントがある。
今回のケースだと、MainActivity の loadimg () 関数内で クラスの初期化に失敗しているのが原因だとわかる
Android Studio 0.5.4 update causes Java.Lang.VerifyError - Stack Overflow
参考になったのがこちら・ω・
やー、参った…。
Comments