Android examples are not working on Virtual Device

Guys, I am able to build all the android examples on eclipse by following the android eclipse setup guidelines for linux but still am unable to run them on android virtual device. Please let me know what I am doing wrong.

Here’s my system info:

OS: Ubuntu 11.10
Eclipse IDE for C/C++ 3.7.1
Android API: 2.2
Android NDK: r5b
OF: Downloaded from github

The androidexamples are building fine but still am unable to run them on emulator. For example if I try to run androidPolygonExample on Virtual Device with API 2.2 it exits with the following error that “the application androidPolygonExample (process cc.openframeworks.androidpolygonexample) has stopped unexpectedly. Please try again.”

Here’s what the error log says:

03-08 00:24:19.986: I/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=cc.openframeworks.androidPolygonExample/.OFActivity }
03-08 00:24:20.056: I/ActivityManager(59): Start proc cc.openframeworks.androidPolygonExample for activity cc.openframeworks.androidPolygonExample/.OFActivity: pid=269 uid=10036 gids={1015}
03-08 00:24:20.236: D/AndroidRuntime(269): Shutting down VM
03-08 00:24:20.236: W/dalvikvm(269): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-08 00:24:20.266: E/AndroidRuntime(269): FATAL EXCEPTION: main
03-08 00:24:20.266: E/AndroidRuntime(269): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cc.openframeworks.androidPolygonExample/cc.openframeworks.androidPolygonExample.OFActivity}: java.lang.ClassNotFoundException: cc.openframeworks.androidPolygonExample.OFActivity in loader dalvik.system.PathClassLoader[/data/app/cc.openframeworks.androidPolygonExample-1.apk]
03-08 00:24:20.266: E/AndroidRuntime(269): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
03-08 00:24:20.266: E/AndroidRuntime(269): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-08 00:24:20.266: E/AndroidRuntime(269): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-08 00:24:20.266: E/AndroidRuntime(269): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-08 00:24:20.266: E/AndroidRuntime(269): at android.os.Handler.dispatchMessage(Handler.java:99)
03-08 00:24:20.266: E/AndroidRuntime(269): at android.os.Looper.loop(Looper.java:123)
03-08 00:24:20.266: E/AndroidRuntime(269): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-08 00:24:20.266: E/AndroidRuntime(269): at java.lang.reflect.Method.invokeNative(Native Method)
03-08 00:24:20.266: E/AndroidRuntime(269): at java.lang.reflect.Method.invoke(Method.java:521)
03-08 00:24:20.266: E/AndroidRuntime(269): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-08 00:24:20.266: E/AndroidRuntime(269): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-08 00:24:20.266: E/AndroidRuntime(269): at dalvik.system.NativeStart.main(Native Method)
03-08 00:24:20.266: E/AndroidRuntime(269): Caused by: java.lang.ClassNotFoundException: cc.openframeworks.androidPolygonExample.OFActivity in loader dalvik.system.PathClassLoader[/data/app/cc.openframeworks.androidPolygonExample-1.apk]
03-08 00:24:20.266: E/AndroidRuntime(269): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
03-08 00:24:20.266: E/AndroidRuntime(269): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
03-08 00:24:20.266: E/AndroidRuntime(269): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
03-08 00:24:20.266: E/AndroidRuntime(269): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
03-08 00:24:20.266: E/AndroidRuntime(269): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
03-08 00:24:20.266: E/AndroidRuntime(269): … 11 more
03-08 00:24:20.285: W/ActivityManager(59): Force finishing activity cc.openframeworks.androidPolygonExample/.OFActivity
03-08 00:24:20.785: W/ActivityManager(59): Activity pause timeout for HistoryRecord{44fb89d0 cc.openframeworks.androidPolygonExample/.OFActivity}

Can you try deleting everything in bin (other than bin/data), obj, gen, and libs, and recompile again? I’ve had problems with leftover binaries not being thoroughly replaced.

Did you rename your namespace or the OFActivity class?

On a side note, I’ve had some examples not work properly on an emulator (I think androidImageExample) which worked fine on a real device. That doesn’t seem like the problem here, but it might save frustrations in the long run to use a real device

Trex,
I ran into the same issues, not being able to load the main Activity (OFActivity) and having it unexpectedly stop in the Emulator. I’ve tried everything I can think of and read on StackOverflow. Did you resolve this issue?

When I look at my build tree, I don’t see any classes in the bin/classes folder … and the dex looks really small (52kb) … Shouldn’t I expect to see .class files from the build here (before they’re dex-ified?)

I’m building the EmptyExample and using ADT 17. I’m able to build all projects, addons and examples fine, but cannot run them in the emulator.

Thoughts, advice?

OS: MacOS 10.7
ADT 17
Android API: 4.2
Android NDK: r8b
OF: 073