Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

Tags:

android

Ok guys this doesn't make sense to me at all and I don't understand why I am getting this error in my app. I have registered the activity class in the android manifrest xml..

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.mobile.batteryhelper/com.mobile.batteryhelper.Battery}:
java.lang.ClassNotFoundException: Caused by: java.lang.ClassNotFoundException: com.mobile.batteryhelper.Battery in loader dalvik.system.PathClassLoader[/mnt/asec/com.mobile.batteryhelper-1/pkg.apk]

Here is the androidmanifest.xml. Yes the .Battery class extends Activity also.

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".Battery"
              android:label="@string/app_name"
               android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
like image 813
user766380 Avatar asked Jun 22 '11 16:06

user766380


3 Answers

Have you tried to clean your workspace. Goto Project->Clean and select your project. For some reason eclipse doesn't build my manifest automatically.

like image 173
Stefan Bossbaly Avatar answered Nov 15 '22 15:11

Stefan Bossbaly


You have put 3rd party library in library folder and reference them. Go to Properties/ Java Build Path/ Libraries/ Add External JARs.

Check the Jar files in the Properties/ Java Build Path/ Order and Export

like image 22
ElitCenk Avatar answered Nov 15 '22 16:11

ElitCenk


Have you tried to initialise anything in your class before OnCreate gets called?
If you initialise static variables (for example) it can give you this (infuriatingly obtuse) error.

like image 2
DefenestrationDay Avatar answered Nov 15 '22 16:11

DefenestrationDay