Closed artagnon closed 11 years ago
Can you post the adb lines from before the ClassNotFoundException? Is there something about throwing out an invalid class?
I bet this is happening because you've built with Java 7. When I switch over to 7, Mirah generates bytecode that is invalid on Dalvik.
When building, I see lots of this:
trouble processing:
bad class file magic (cafebabe) or version (0033.0000)
...while parsing org/example/hello/BuildConfig.class
...while processing org/example/hello/BuildConfig.class
When running, this:
I/ActivityManager( 389): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.example.hello/.HelloActivity} from pid 687
D/dalvikvm( 3882): Late-enabling CheckJNI
I/ActivityManager( 389): Start proc org.example.hello for activity org.example.hello/.HelloActivity: pid=3882 uid=10099 gids={50099, 1015, 1028}
W/dalvikvm( 3882): VFY: unable to resolve static field 7 (main) in Lorg/example/hello/R$layout;
D/dalvikvm( 3882): VFY: replacing opcode 0x60 at 0x0003
D/AndroidRuntime( 3882): Shutting down VM
W/dalvikvm( 3882): threadid=1: thread exiting with uncaught exception (group=0x41470930)
E/AndroidRuntime( 3882): FATAL EXCEPTION: main
E/AndroidRuntime( 3882): java.lang.NoClassDefFoundError: org.example.hello.R$layout
E/AndroidRuntime( 3882): at org.example.hello.HelloActivity.onCreate(HelloActivity.mirah:8)
E/AndroidRuntime( 3882): at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime( 3882): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
E/AndroidRuntime( 3882): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
E/AndroidRuntime( 3882): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
E/AndroidRuntime( 3882): at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime( 3882): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime( 3882): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 3882): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 3882): at android.app.ActivityThread.main(ActivityThread.java:5039)
E/AndroidRuntime( 3882): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3882): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 3882): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 3882): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 3882): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 389): Force finishing activity org.example.hello/.HelloActivity
W/DropBoxManagerService( 389): Dropping: data_app_crash (1179 > 0 bytes)
W/ActivityManager( 389): Activity pause timeout for ActivityRecord{420f4c58 u0 org.example.hello/.HelloActivity}
The "VFY" lise are dalvik throwing out "bad" opcodes. Mirah needs to update its Java 7 + 1.6 opcode support.
Please reopen if you're running Java 6 and still seeing this.
I'm actually going to reopen this as a "Make Java 7 & Mirah emit proper Dalvik opcodes" ticket.
For posterity, it seems that the bad opcodes were coming from javac -- we hadn't told it which JVM to target, so it was happily emitting 1.7 classfiles.
I built a sample application using
pindah create org.test.chwall2 chwall2 ChwallActivity
, built it and put it on my phone. It crashes on startup. From logcat: