RoboGuice vs me - Unable to instantiate activity ... ClassNotFoundException ...

117 views
Skip to first unread message

yonatan maman

unread,
Apr 2, 2013, 6:11:22 PM4/2/13
to robo...@googlegroups.com
Hi I'm trying to use RoboGuice 2.0 but w/o success so far. 
I've read documentation, and tones of posts/threads/question about similar issues - and couldn't mange to make it work.
I wonder if you guys can help me.

I'm using RoboGuice 2.0 via maven and couldnt get rid of this crash:


04-03 00:37:39.795: E/AndroidRuntime(12619): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.cheetah/com.cheetah.LocationActivity}: java.lang.ClassNotFoundException: com.cheetah.LocationActivity
04-03 00:37:39.795: E/AndroidRuntime(12619): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1892)
04-03 00:37:39.795: E/AndroidRuntime(12619): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
04-03 00:37:39.795: E/AndroidRuntime(12619): at android.app.ActivityThread.access$600(ActivityThread.java:127)
04-03 00:37:39.795: E/AndroidRuntime(12619): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
04-03 00:37:39.795: E/AndroidRuntime(12619): at android.os.Handler.dispatchMessage(Handler.java:99)
04-03 00:37:39.795: E/AndroidRuntime(12619): at android.os.Looper.loop(Looper.java:137)
04-03 00:37:39.795: E/AndroidRuntime(12619): at android.app.ActivityThread.main(ActivityThread.java:4507)
04-03 00:37:39.795: E/AndroidRuntime(12619): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 00:37:39.795: E/AndroidRuntime(12619): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 00:37:39.795: E/AndroidRuntime(12619): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
04-03 00:37:39.795: E/AndroidRuntime(12619): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
04-03 00:37:39.795: E/AndroidRuntime(12619): at dalvik.system.NativeStart.main(Native Method)
04-03 00:37:39.795: E/AndroidRuntime(12619): Caused by: java.lang.ClassNotFoundException: com.cheetah.LocationActivity
04-03 00:37:39.795: E/AndroidRuntime(12619): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
04-03 00:37:39.795: E/AndroidRuntime(12619): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-03 00:37:39.795: E/AndroidRuntime(12619): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-03 00:37:39.795: E/AndroidRuntime(12619): at android.app.Instrumentation.newActivity(Instrumentation.java:1026)
04-03 00:37:39.795: E/AndroidRuntime(12619): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1883)

Here are my files
(part of) pom.xml:
....
    <dependency>
      <groupId>org.roboguice</groupId>
      <artifactId>roboguice</artifactId>
      <version>2.0</version>
    </dependency>
...

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
    package="com.cheetah"
    android:versionCode="1"
    android:versionName="trunk" >

    <instrumentation android:name="android.test.InstrumentationTestRunner" android:label="your tests label" android:targetPackage="com.cheetah" />

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <uses-library android:name="android.test.runner" />
        <activity
            android:name=".LocationActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>


(digest of) com.cheetah,LocationActivity:

@ContentView(R.layout.main)
public class LocationActivity extends RoboActivity implements ILocationView {
  @InjectView(R.id.debug)
  TextView debugView;
....
  protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
 }
....
}


res/values/roboguice.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="UnusedResources"> 
  <string-array name="roboguice_modules">
    <item>com.cheetah.MyModule</item>
  </string-array>
</resources>

com.cheetah.MyModule

public class MyModule extends AbstractModule {

  @Override
  protected void configure() {
    bind(ILocationController.class).to(LocationController.class);
   ....
  }
}

as I'm using proguard I've hacked the dex file and find all roboGuice and guice classes, as well as my classes
Do I miss something ?

Michael Burton

unread,
Apr 3, 2013, 9:52:27 AM4/3/13
to robo...@googlegroups.com

It sounds like proguard is stripping out your activity class.

--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To unsubscribe from this group and stop receiving emails from it, send an email to roboguice+...@googlegroups.com.
To post to this group, send email to robo...@googlegroups.com.
Visit this group at http://groups.google.com/group/roboguice?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages