java.lang.RuntimeException: Unable to instantiate activity ComponentInfo/ ClassNotFoundException

我只是一个虾纸丫 提交于 2019-11-29 01:39:01

When upgrading, the 'Order and Export' of the new 'Android Private Libraries' is not always checked. And the android-support-v4.jar is now in this 'Android Private Libraries' section.

To fix this, go to 'Order and Export' and check 'Android Private Libraries'. Then refresh/clean/rebuild.

After you done this 'fix' for a library project, you may need to just close and re-open any depending project, because they may not see this 'fix' immediately.

change your activity declaration in the manifest file into

 <activity android:name=".UnlockActivity">

or else

<activity android:name="Yourcompletepackagename.UnlockActivity">

and try

Rowinson Gallego

Dude, this also happened to me when my app was already published in the marketplace. It was a total disaster. I realized it after 5 hours of already publishing it.

There was no problem by running it with the ADT. Problem was with the generated APK. So if you publish an app, test the installation of the pure APK in your test phone.

As you, I also think that problem was with the the update of my ADT, in my case v22.

The solution was to clean and build the project:

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

This can happen if your activity class is inside a default package. I fixed it by moving the activity class to a new package. and changing the manifest.xml

before

activity android:name=".MainActivity"

after

activity android:name="new_package.MainActivity"

I had the same problem, but I had my activity declared in the Manifest file, with the correct name.

My problem was that I didn't have to imported a third party libraries in a "libs" folder, and I needed reference them in my proyect (Right-click, properties, Java Build Path, Libraries, Add Jar...).

About how do you declare an activity in the manifest file, is correct use .ActivityName always that activity be in the main package.

I agree with what @codercat has advised you to do, but this error also comes when you are using v7 and also v13 in the same project structure for different functionalities. Therefore, i advice you to copy the v13 jar file into the libs folder (DO NOT import it as an external jar) and then check the android libraries and android dependencies. Refresh you project and then clean your project. I am sure the error you are facing will go away.

i also having same problem and i just turn off build automatically and build my android project manually and cleaned my project that solved this error for me

change line from

<activity android:name=".activities.UnlockActivity">  

to

<activity android:name=".com.bvblogic.android.batterypower.activities.UnlockActivity
 ">

Cleaning the project worked for me. You might ask me what led to the issue? LOL I tried to upgrade a project to android 5 from 4.4 and then changed my mind and tried to restore it back to kitkat, then voila! this error came up.

Javed Tahasildar

you might have declared String a = edt.getText().toString(); or int 5/3 hence such errors use to come

so,
declare them in onCreate method error will resolved

Tell Me How

I solve this problem by remove package name(com.blogspot.geekonjava) from AndroidManifest.xml like :

<activity
            android:name="com.blogspot.geekonjava.MainActivity"
            android:theme="@style/Theme.AppCompat.Light"
            android:label="@string/app_name" >

to

<activity
            android:name=".MainActivity"
            android:theme="@style/Theme.AppCompat.Light"
            android:label="@string/app_name" >

It work for me hope it works for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!