android-plugin icon indicating copy to clipboard operation
android-plugin copied to clipboard

Disabling proguard causes class not found error in unmodified HelloWorld project

Open oconnor663 opened this issue 13 years ago • 2 comments

I create a new project with proguard disabled like this:

$ g8 jberkel/android-app

Template for Android apps in Scala 

package [my.android.project]: com.example.probug
name [My Android Project]: ProBug
main_activity [MainActivity]: 
scala_version [2.9.2]: 
api_level [10]: 16
useProguard [true]: false    <---- note this
scalatest_version [1.8]: 

Template applied in ./probug

Then without changing anything, I launch the new project on my device:

$ sbt android:start-device

The app crashes with the following error

I/ActivityManager(  316): Start proc com.example.probug for activity com.example.probug/.MainActivity: pid=24975 uid=10084 gids={1028}
D/ActivityThread(24975): setTargetHeapUtilization:0.25
D/ActivityThread(24975): setTargetHeapIdealFree:8388608
D/ActivityThread(24975): setTargetHeapConcurrentStart:2097152
I/dalvikvm(24975): Failed resolving Lcom/example/probug/TypedViewHolder; interface 44 'Lscala/ScalaObject;'
W/dalvikvm(24975): Link of class 'Lcom/example/probug/TypedViewHolder;' failed
I/dalvikvm(24975): Failed resolving Lcom/example/probug/TypedActivityHolder; interface 27 'Lcom/example/probug/TypedViewHolder;'
W/dalvikvm(24975): Link of class 'Lcom/example/probug/TypedActivityHolder;' failed
I/dalvikvm(24975): Failed resolving Lcom/example/probug/TypedActivity; interface 16 'Lcom/example/probug/TypedActivityHolder;'
W/dalvikvm(24975): Link of class 'Lcom/example/probug/TypedActivity;' failed
I/dalvikvm(24975): Failed resolving Lcom/example/probug/MainActivity; interface 15 'Lcom/example/probug/TypedActivity;'
W/dalvikvm(24975): Link of class 'Lcom/example/probug/MainActivity;' failed
D/AndroidRuntime(24975): Shutting down VM
W/dalvikvm(24975): threadid=1: thread exiting with uncaught exception (group=0x40e7d300)
E/AndroidRuntime(24975): FATAL EXCEPTION: main
E/AndroidRuntime(24975): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.probug/com.example.probug.MainActivity}: java.lang.ClassNotFoundException: com.example.probug.MainActivity
E/AndroidRuntime(24975):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
E/AndroidRuntime(24975):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2210)
E/AndroidRuntime(24975):        at android.app.ActivityThread.access$600(ActivityThread.java:142)
E/AndroidRuntime(24975):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1208)
E/AndroidRuntime(24975):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(24975):        at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(24975):        at android.app.ActivityThread.main(ActivityThread.java:4931)
E/AndroidRuntime(24975):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(24975): Caused by: java.lang.ClassNotFoundException: com.example.probug.MainActivity
E/AndroidRuntime(24975):        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime(24975):        at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime(24975):        at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime(24975):        at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
E/AndroidRuntime(24975):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2090)
E/AndroidRuntime(24975):        ... 11 more
W/ActivityManager(  316):   Force finishing activity com.example.probug/.MainActivity

I'm a beginner with Android apps, so I don't really know what to try with proguard. Any suggestions for what to try?

oconnor663 avatar Jan 06 '13 22:01 oconnor663

I am also seeing this issue. I disabled Proguard because it was not working with Java 7. Any ideas?

JanxSpirit avatar Mar 14 '13 16:03 JanxSpirit

ProGuard is required to dex Scala libraries. If you want to disable ProGuard, please refer to these resources.

https://github.com/jberkel/android-plugin/issues/114 https://github.com/jberkel/android-plugin/wiki/Predex https://groups.google.com/forum/#!topic/scala-on-android/-j_CIRzANuQ

shinichy avatar Jun 19 '13 08:06 shinichy