0

am getting this exception:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{business.premium/business.premium.Problemio}: 
java.lang.ClassNotFoundException: business.premium.Problemio
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
        at android.app.ActivityThread.access$600(ActivityThread.java:123)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4424)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
        at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: business.premium.Problemio
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
        ... 11 more
java.lang.ClassNotFoundException: business.premium.Problemio
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
        at android.app.ActivityThread.access$600(ActivityThread.java:123)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4424)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
        at dalvik.system.NativeStart.main(Native Method)

it says that class is not there, but it IS there. I tried to configure things in my project's build path, but not too sure what to tweak there.

And here is how I start my Manifest file:

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

    <supports-screens  android:largeScreens="true"   android:normalScreens="true"  android:smallScreens="true"/> 

    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15"/>
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" 
        android:theme="@style/CustomTheme" 
        android:name="MyApplication"
        android:debuggable="true">
        <activity
            android:name=".Problemio"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

Any thoughts on how to solve this, or what to look into? Thanks!

Genadinik
  • 18,153
  • 63
  • 185
  • 284
  • 1
    Check your AndroidManifest and package of the class – Dmitriy Tarasov Oct 03 '12 at 14:10
  • @ Dmitriy Tarasov what do you mean? Check for what specifically? I am looking at it, and it looks reasonable. – Genadinik Oct 03 '12 at 14:12
  • Have you included business.premium.Problemio in your manifest? – Shrikant Ballal Oct 03 '12 at 14:13
  • @Shrikant yeah, I just updated my question with that bit from the manifest in a second. – Genadinik Oct 03 '12 at 14:15
  • Check package name. It is even better to perform global search thru your sources and try to find package names from project which you used to copy-paste the code. I suppose that the problem is in package names. Also check proguard configs if you using it and try to clean and rebuild your project – Dmitriy Tarasov Oct 03 '12 at 14:18
  • I have never used: **android:name** in the Application Tag. Looking into the docs, it says: The fully qualified name of an Application subclass implemented for the application. When the application process is started, this class is instantiated before any of the application's components. The subclass is optional; most applications won't need one. In the absence of a subclass, Android uses an instance of the base Application class. Is it needed? – Shrikant Ballal Oct 03 '12 at 14:22
  • @Shrikant interesting point - I use it to instantiate the ARCA library for error reporting. It works in the other project. But from what I had read, it might have something to do with the new project's libs directory....not sure – Genadinik Oct 03 '12 at 14:23
  • Please see this: http://stackoverflow.com/questions/3781151/java-lang-classnotfoundexception-on-working-app The phreakhead's answer is somewhat similar to your problem. – Shrikant Ballal Oct 03 '12 at 14:37
  • @Shrikant I took out the name reference already, but I am still getting the crash :( – Genadinik Oct 03 '12 at 14:40

1 Answers1

1

Its because you specified the "android:name" attribute in the application node in the manifest file.

Do not use the android:name attribute!

It, misleadingly, does not have anything to do with the name of your app and is actually the name of an extra class to load before loading your application. That's why you are getting the ClassNotFoundException.

Remove it and it should work:

<application 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:description="@string/help_text" >

This answer is taken from: java.lang.ClassNotFoundException on working app

Community
  • 1
  • 1
Shrikant Ballal
  • 7,067
  • 7
  • 41
  • 61