1

I am getting the following error every time I run my android app on an AVD. The app crashes almost instantly upon running it:

    08-24 02:18:01.629: E/AndroidRuntime(1860): FATAL EXCEPTION: main
08-24 02:18:01.629: E/AndroidRuntime(1860): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.zamani.randomizedworkout/com.zamani.randomizedworkout.MainScreen}: java.lang.ClassNotFoundException: Didn't find class "com.zamani.randomizedworkout.MainScreen" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.zamani.randomizedworkout-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.zamani.randomizedworkout-2, /system/lib]]
08-24 02:18:01.629: E/AndroidRuntime(1860):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at android.os.Looper.loop(Looper.java:137)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at android.app.ActivityThread.main(ActivityThread.java:5103)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at java.lang.reflect.Method.invokeNative(Native Method)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at java.lang.reflect.Method.invoke(Method.java:525)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at dalvik.system.NativeStart.main(Native Method)
08-24 02:18:01.629: E/AndroidRuntime(1860): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.zamani.randomizedworkout.MainScreen" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.zamani.randomizedworkout-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.zamani.randomizedworkout-2, /system/lib]]
08-24 02:18:01.629: E/AndroidRuntime(1860):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
08-24 02:18:01.629: E/AndroidRuntime(1860):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
08-24 02:18:01.629: E/AndroidRuntime(1860):     ... 11 more

Also, here is my AndroidManifest:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.zamani.randomizedworkout"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <instrumentation
        android:name="android.test.InstrumentationTestRunner"
        android:targetPackage="com.zamani.randomizedworkout" />

    <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="com.zamani.randomizedworkout"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.zamani.randomizedworkout.WorkoutScreen"
            android:label="com.zamani.randomizedworkout.MyActivityLib:string/app_name" >
        </activity>
    </application>

</manifest>

Some additional info regarding my issue: I have included both of my activities in my AndroidManifest, which is shown above, so unless I am missing something I'm not sure that's the issue I am having. My app worked perfectly fine until I upgraded the SDK version from 17 to 18 a few days back, so maybe that is part of my problem. I've checked several other StackOverflow threads on similar issues, and I didn't find a solution that solved my problem. Any help would be greatly appreciated!

1
  • That didn't seem to help, as I already had the Android Private Libraries selected. Commented Aug 24, 2013 at 17:29

2 Answers 2

1

Try This:

        <activity
            android:name="com.zamani.randomizedworkout.MainScreen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
Sign up to request clarification or add additional context in comments.

3 Comments

Unfortunately that didn't solve the problem, as it still crashes with the same error when I run it.
@MikeZ which is your main activity? replace MainScreen with the name of Main Activity in the above code
@Raghunadan MainScreen is the main activity of the project. I'm using a library in which my activities extend a "Screen" superclass to simplify some aspects. But the application worked perfectly fine up until I changed from version 17 to 18. Perhaps I should try creating a project from scratch and copy my code and activities into that?
0

I had a similar problem, but restarting the device after installing my app solved the problem. But now the problem is, I have to do it every time to be able to run the app.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.