Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication ?Android

AndroidAndroid StudioGradleInstant Run

Android Problem Overview


I updated my Android Studio to version 2.0. But I had a problem, I don't know why?

The important error info:

> Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.IllegalStateException: java.lang.ClassNotFoundException: com.eallcn.rentagent.MyDebugEallApplication

I searched a long time, But I didn't find the right answer you can see the link

At the same time when I click File->Project structure It shows this error:

enter image description here

Is there any problem somewhere in the libs? When gradle build the program the libs didn't load completely for current program. Is there any problem with Android Studio version 2.0?

When I use Android studio 1.4.0 to build and run the program. It works fine for me! But when I use the Android Studio 2.0, the problem shows up!

Why? Could you help me, please?

Here is detailed error log:

>11-28 11:57:00.489 19890-19890/com.eallcn.rentagent.debug >E/AndroidRuntime: FATAL EXCEPTION: main >Process: com.eallcn.rentagent.debug, PID: 19890 java.lang.RuntimeException: Unable to instantiate application > com.android.tools.fd.runtime.BootstrapApplication: > java.lang.IllegalStateException: java.lang.ClassNotFoundException: > com.eallcn.rentagent.MyDebugEallApplication > at android.app.LoadedApk.makeApplication(LoadedApk.java:537) at > android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586) > at android.app.ActivityThread.access$1800(ActivityThread.java:139)
> at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
> at android.os.Handler.dispatchMessage(Handler.java:102)
> at android.os.Looper.loop(Looper.java:136)
> at android.app.ActivityThread.main(ActivityThread.java:5314)
> at java.lang.reflect.Method.invokeNative(Native Method)
> at java.lang.reflect.Method.invoke(Method.java:515)
> at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864) > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)
> at dalvik.system.NativeStart.main(Native Method)
> Caused by: java.lang.IllegalStateException: > java.lang.ClassNotFoundException: > com.eallcn.rentagent.MyDebugEallApplication
> at > com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:167) > at > com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:179) > at android.app.Application.attach(Application.java:194)
> at > android.app.Instrumentation.newApplication(Instrumentation.java:992)
> at > android.app.Instrumentation.newApplication(Instrumentation.java:976)
> at android.app.LoadedApk.makeApplication(LoadedApk.java:532)
> at > android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586)  > at android.app.ActivityThread.access$1800(ActivityThread.java:139)  > at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)  > at android.os.Handler.dispatchMessage(Handler.java:102)  > at android.os.Looper.loop(Looper.java:136)  > at android.app.ActivityThread.main(ActivityThread.java:5314)  > at java.lang.reflect.Method.invokeNative(Native Method)  > at java.lang.reflect.Method.invoke(Method.java:515)  > at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)  > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)  > at dalvik.system.NativeStart.main(Native Method)  > Caused by: java.lang.ClassNotFoundException: > com.eallcn.rentagent.MyDebugEallApplication > at java.lang.Class.classForName(Native Method) > at java.lang.Class.forName(Class.java:251) > at java.lang.Class.forName(Class.java:216) > at > com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:155) > at > com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:179)  > at android.app.Application.attach(Application.java:194)  > at > android.app.Instrumentation.newApplication(Instrumentation.java:992)  > at > android.app.Instrumentation.newApplication(Instrumentation.java:976)  > at android.app.LoadedApk.makeApplication(LoadedApk.java:532)  > at > android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586)  > at android.app.ActivityThread.access$1800(ActivityThread.java:139)  > at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)  > at android.os.Handler.dispatchMessage(Handler.java:102)  > at android.os.Looper.loop(Looper.java:136)  > at android.app.ActivityThread.main(ActivityThread.java:5314)  > at java.lang.reflect.Method.invokeNative(Native Method)  > at java.lang.reflect.Method.invoke(Method.java:515)  > at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)  > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)  > at dalvik.system.NativeStart.main(Native Method)  > Caused by: java.lang.NoClassDefFoundError: > com/eallcn/rentagent/MyDebugEallApplication > at java.lang.Class.classForName(Native Method)  > at java.lang.Class.forName(Class.java:251)  > at java.lang.Class.forName(Class.java:216)  > at > com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:155)  > at > com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:179)  > at android.app.Application.attach(Application.java:194)  > at > android.app.Instrumentation.newApplication(Instrumentation.java:992)  > at > android.app.Instrumentation.newApplication(Instrumentation.java:976)  > at android.app.LoadedApk.makeApplication(LoadedApk.java:532)  > at > android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586)  > at android.app.ActivityThread.access$1800(ActivityThread.java:139)  > at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)  > at android.os.Handler.dispatchMessage(Handler.java:102)  > at android.os.Looper.loop(Looper.java:136)  > at android.app.ActivityThread.main(ActivityThread.java:5314)  > at java.lang.reflect.Method.invokeNative(Native Method)  > at java.lang.reflect.Method.invoke(Method.java:515)  > at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)  > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)  > at dalvik.system.NativeStart.main(Native Method)  > Caused by: java.lang.ClassNotFoundException: Didn't find class > "com.eallcn.rentagent.MyDebugEallApplication" on path: > DexPathList[[zip file > "/data/app/com.eallcn.rentagent.debug-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.eallcn.rentagent.debug-1, > /vendor/lib, /system/lib, /data/datalib]] > at > dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) > at java.lang.ClassLoader.loadClass(ClassLoader.java:497) > at java.lang.ClassLoader.loadClass(ClassLoader.java:457) > at java.lang.Class.classForName(Native Method)  > at java.lang.Class.forName(Class.java:251)  > at java.lang.Class.forName(Class.java:216)  > at > com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:155)  > at > com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:179)  > at android.app.Application.attach(Application.java:194)  > at > android.app.Instrumentation.newApplication(Instrumentation.java:992)  > at > android.app.Instrumentation.newApplication(Instrumentation.java:976)  > at android.app.LoadedApk.makeApplication(LoadedApk.java:532)  > at > android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586)  > at android.app.ActivityThread.access$1800(ActivityThread.java:139)  > at > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)  > at android.os.Handler.dispatchMessage(Handler.java:102)  > at android.os.Looper.loop(Looper.java:136)  > at android.app.ActivityThread.main(ActivityThread.java:5314)  > at java.lang.reflect.Method.invokeNative(Native Method)  > at java.lang.reflect.Method.invoke(Method.java:515)  > at > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)  > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)  > at dalvik.system.NativeStart.main(Native Method)

 

Android Solutions


Solution 1 - Android

Disable the Instant Run option in Android Studio. Instructions are in the Android Studio Instant Run documentation.

Instant Run tries to do hot swapping of your code; this causes the application class to be moved.

To disable Instant Run Go to File --> Settings--> Build,Execution,Deployment -->Instant Run ---> uncheck "Enable instant run"

Solution 2 - Android

I had the same error after trying to use the 2.0.

I solved it by reverting some gradle changes:

1/3:

Changing:

classpath 'com.android.tools.build:gradle:2.0.0-alpha1'

By:

classpath 'com.android.tools.build:gradle:1.2.3'

2/3:

Changing:

buildToolsVersion '23.0.2'

By:

buildToolsVersion "21.1.2"

3/3: (in <project folder>/.idea/gradle.xml)

And:

<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.8" />

By:

<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.4" />

I don't know what line is exactly the origin of the error, but with this three changes it was solved.

Hope that it helps you :)

Solution 3 - Android

I had the same error.

I solved it by cleaning the project ( Build > Clean Project )

Solution 4 - Android

Just go to Android Studio menu - Build --> Rebuild Project.

Solution 5 - Android

I was able to get rid of this error by updating gradle-wrapper.properties to gradle-2.14.1-all, and cleaning/rebuilding the project. Then it ran fine. No other changes were needed (as those suggested in the above answer)...

Solution 6 - Android

Changing to

classpath 'com.android.tools.build:gradle:2.0.0-alpha6'

fixed issue

Solution 7 - Android

I also got this error with Android 2.0 in stable channel.

What I did?

  • I had an older version of the app already installed on the device (which was built using older version of the Studio) which I was trying to replace by running the newer app on device.
    I just uninstalled the older version completely before running the new app and the trick worked.

Solution 8 - Android

Just for those who want to update classPath with latest gradle plugin version, Where to find latest plugin version?

Check in http://tools.android.com/tech-docs/new-build-system and update your classPath. Latest one at current is

 classpath 'com.android.tools.build:gradle:2.0.0'.

Always try to build with latest plugin version.

Solution 9 - Android

If you don't want to disable Instant Run, just do a project clean and rerun.

Solution 10 - Android

Change classpath 'com.android.tools.build:gradle:2.1.2' to classpath 'com.android.tools.build:gradle:2.1.0' fixes my problem.

Solution 11 - Android

I also faced the same problem and i solved it. In my case it was due to a mistake in global class ( Throughout Application context class ) , my mistake was in AndroidManifest.xml i have declared the Application class VolleyHelper as :-

 <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true" android:name=".VolleyHelper"
        android:theme="@style/AppTheme"> 

but in VolleyHelper.java i don't have a Default constructor . So i added default constructor in VolleyHelper.java ( Application Class ) .

Solution 12 - Android

you can also add this into your gradle to prevent making dex on debug

debug {
    // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
    // to pre-dex each module and produce an APK that can be tested on
    // Android Lollipop without time consuming dex merging processes.
    minSdkVersion 21
}

Solution 13 - Android

This error will happen when you add a blank activity with .java file. So to solve this error 1st you have to Build the project again. Then run it. Solved Thank You.

Solution 14 - Android

In some Android devices with versions before OS 5.0 we get the error message:

> Caused by: java.lang.ClassNotFoundException: Didn't find class > "com.android.tools.fd.runtime.BootstrapApplication

We must disable "Instant Run".

Go to File > Settings > Built, Execution, Deployment > Instant Run

Then disable the option Enable Instant Run to hot swap code.

enter image description here

Solution 15 - Android

I just needed to reboot my device. Tried everything else first unfortunately so wasted hours.

Solution 16 - Android

If you are sharing your app then another solution is

go to Android Studio --> Build --> Build APK

A pop up will come with APK generated successfully. Show in Explorer will get you to the generated apk folder.

Solution 17 - Android

No need to disable "instant run".

  1. go to project's root using File Explorer
  2. Finish Android Studio(AS)
  3. delete(relocate somewhere) ".gradle" 's folder content
    (to clean some cashs and old artifacts)
  4. in res folder clean off all inappropriate files
  5. launch the AS again
  6. in module's build.gradle set "buildTypes { debug {minifyEnabled true" to false
    (that looks like an error was in my proguard file, kek)

Sync, compile and run the app again :/

Solution 18 - Android

I just update Android Studio to the last version (2.0 Beta 5). It changes itself to classpath 'com.android.tools.build:gradle:2.0.0-beta5' and works like a charm.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGeekHadesView Question on Stackoverflow
Solution 1 - Androidpeeyush pathakView Answer on Stackoverflow
Solution 2 - AndroidemmgfxView Answer on Stackoverflow
Solution 3 - AndroidCalixtoView Answer on Stackoverflow
Solution 4 - AndroidNarendra SinghView Answer on Stackoverflow
Solution 5 - AndroidIgorGanapolskyView Answer on Stackoverflow
Solution 6 - Androidar-gView Answer on Stackoverflow
Solution 7 - AndroidbsguruView Answer on Stackoverflow
Solution 8 - AndroidMahendra ChhimwalView Answer on Stackoverflow
Solution 9 - AndroideasycheeseView Answer on Stackoverflow
Solution 10 - AndroidAhmed MostafaView Answer on Stackoverflow
Solution 11 - Androidkumar kundanView Answer on Stackoverflow
Solution 12 - Androiduser3682694View Answer on Stackoverflow
Solution 13 - AndroidSiddhant SenapatiView Answer on Stackoverflow
Solution 14 - AndroidJorgesysView Answer on Stackoverflow
Solution 15 - AndroidAnthonyView Answer on Stackoverflow
Solution 16 - AndroidMohammad TauqirView Answer on Stackoverflow
Solution 17 - AndroidCodeToLifeView Answer on Stackoverflow
Solution 18 - AndroidMr.MoustardView Answer on Stackoverflow