Android: Unable to Instantiate Activity/Classnotfoundexception

Unable to instantiate activity Component Info Class Not found exception Android

As Discussion in chat i found that, Your manual way of generating APK
is not generating the correct APK, so i am Suggesting these way to
generating APK for Manual Install:

For Debug Build

  • Delete you build folder inside the App folder.
  • Goto Build>Build APk. it will generate .apk file in your
    app>build>output>apk directory.
  • COPY it your device and install manually.

For Release Build

  • Delete you build folder inside the App folder.
  • Goto Build>Generate Signed APk and provide recomended Details, make sure your Build type : release and have checked both signature version v1(jar signature) and v2(full apk signature) . it will generate .apk file in your
    app>build>output>apk directory.
  • COPY it your device and install manually.

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

It is a problem of your Intent.

Please add your Activity in your AndroidManifest.xml.

When you want to make a new activity, you should register it in your AndroidManifest.xml.

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

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.

Sample Image

Android - Unable to instantiate activity

The problem fixed itself after some updates to android studio!

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

What is your logcat throws

Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.example.imran.justjava.MainActivity"

ClassNotFoundException : ClassNotFoundException occurs when class loader could not find the required class in class path . So , basically you should check your class path and add the class in the classpath.

I guess your activity in manifest is not correct.

Post your manifest.xml .

Have a look here
https://developer.android.com/intl/es/samples/BasicContactables/AndroidManifest.html

Example

<activity
android:name=".MainActivity"
>

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

</activity>

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo for Kotlin MainActivity

Try to apply kotlin in build.gradle file at starting

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion 28

Android - Unable to instantiate activity - Class not found exception after upgrading to ADT 22

Might be a duplicate of this.

Try going to Project -> Properties -> Java Build Path -> Order & Export and ensure
Android Private Libraries are checked for your project and for all other library projects you are using. Clean all projects
afterwards and see what happens.



Related Topics



Leave a reply



Submit