Android java.lang.ClassNotFoundException: Didn't find class - android

I'm a total Android newbie here, so hopefully someone can help me out.
I have an Android library (myLib.aar) that I am including/using in the HelloAR demo app.
Now, I want to use Instacapture within myLib.aar. I followed the instructions on the README:
dependencies {
...
compile "com.github.tarek360:instacapture:2.0.1"
}
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
I also tried downloading, compiling instacapture source, adding the instacapture.aar to my libs dir and modifying my Gradle files:
dependencies{
...
implementation(name:'instacapture', ext:'aar')
}
allprojects {
repositories {
...
flatDir {
dirs 'libs'
}
}
In both cases, I get the following exception:
--------- beginning of crash
2020-08-11 22:34:35.965 32761-32761/com.google.ar.core.examples.java.helloar E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.ar.core.examples.java.helloar, PID: 32761
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/tarek360/instacapture/Instacapture;
at com.cambridge.myLib.ScreenShotter.takeScreenshot(ScreenShotter.java:139)
at com.google.ar.core.examples.java.helloar.HelloArActivity$2.run(HelloArActivity.java:164)
at com.google.ar.core.examples.java.helloar.HelloArActivity.startRepeatingTask(HelloArActivity.java:171)
at com.google.ar.core.examples.java.helloar.HelloArActivity$1.run(HelloArActivity.java:152)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.tarek360.instacapture.Instacapture" on path: DexPathList[[zip file "/data/app/com.google.ar.core.examples.java.helloar-bhCcJ--GEjsJ6mxAFvnUYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.google.ar.core.examples.java.helloar-bhCcJ--GEjsJ6mxAFvnUYw==/lib/arm64, /data/app/com.google.ar.core.examples.java.helloar-bhCcJ--GEjsJ6mxAFvnUYw==/base.apk!/lib/arm64-v8a, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.cambridge.myLib.ScreenShotter.takeScreenshot(ScreenShotter.java:139)
at com.google.ar.core.examples.java.helloar.HelloArActivity$2.run(HelloArActivity.java:164)
at com.google.ar.core.examples.java.helloar.HelloArActivity.startRepeatingTask(HelloArActivity.java:171)
at com.google.ar.core.examples.java.helloar.HelloArActivity$1.run(HelloArActivity.java:152)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8107)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
However, if I add the dependencies to the main HelloAR app (as per the instructions in the README), the issue resolves.
Can someone please explain what is going on, why I'm getting the error, and how to resolve it without having to add the dependencies to the main HelloAR app?

Considering your quote,
I'm a total Android newbie here, so hopefully someone can help me out.
Follow these steps (in android studio) :
Go to build menu.
Clean the project by clicking on clean project.
Build the project by clicking on make project.
This process is known as clean build which is usually done after adding some dependencies.

Related

Resource linking fails on lStar with error

I'm working on a android Native application. My Android builds began to fail without any changes.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':etndoorcontrol:processHesuan_faceDebugResources'.
> Android resource linking failed
C:\Users\xqf\.gradle\caches\transforms-2\files-2.1\fe7b90aa462d9a2e04dd8216aa450a51\res\values\values.xml:2422:5-2449:25: AAPT: error: resource android:attr/lStar not found.
error: failed linking references.
Then I tried 2 solutions
//soultion 1.
configurations.all {
resolutionStrategy {
// Java language implementation
force "androidx.core:core:1.6.0"
// Kotlin
force "androidx.core:core-ktx:1.6.0"
}
}
After I add this to app/build.gradle, the app can build correct.but after I install the apk and run .there is a new problem.
java stacktrace:
java.lang.NoClassDefFoundError: androidx.appcompat.widget.Toolbar
at libcore.reflect.InternalNames.getClass(InternalNames.java:55)
at java.lang.Class.getDexCacheType(Class.java:2551)
at java.lang.reflect.AbstractMethod.getParameterTypes(AbstractMethod.java:169)
at java.lang.reflect.Method.getParameterTypes(Method.java:193)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingReflectionInSingleClass(SubscriberMethodFinder.java:163)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingInfo(SubscriberMethodFinder.java:88)
at org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:64)
at org.greenrobot.eventbus.EventBus.register(EventBus.java:140)
at com.yarward.a10doorcontrol.homepage.HomePageActivity.initFields(HomePageActivity.java:334)
at com.yarward.base.mvp.view.BaseActivity.onCreate(BaseActivity.java:82)
at com.yarward.a10doorcontrol.homepage.HomePageActivity.onCreate(HomePageActivity.java:257)
at android.app.Activity.performCreate(Activity.java:6709)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2628)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2736)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1487)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6157)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
Caused by: java.lang.ClassNotFoundException: androidx.appcompat.widget.Toolbar
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at libcore.reflect.InternalNames.getClass(InternalNames.java:53)
... 22 more
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/view/MenuHost;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at libcore.reflect.InternalNames.getClass(InternalNames.java:53)
at java.lang.Class.getDexCacheType(Class.java:2551)
at java.lang.reflect.AbstractMethod.getParameterTypes(AbstractMethod.java:169)
at java.lang.reflect.Method.getParameterTypes(Method.java:193)
at java.lang.Class.getDeclaredMethods(Class.java:1812)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingReflectionInSingleClass(SubscriberMethodFinder.java:154)
... 18 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.view.MenuHost" on path: DexPathList[[zip file "/data/app/com.yarward.hesuanface-1/base.apk"],nativeLibraryDirectories=[/data/app/com.yarward.hesuanface-1/lib/arm, /data/app/com.yarward.hesuanface-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 28 more
After this, I tried the other solution, as below:
ext{
androidX = 1.6.0
}
but this is not working for me.
axel8888 thank your sir, yes, I have solved this problem. yes, you are right , when I try solution one again
configurations.all {
resolutionStrategy {
// Java language implementation
force "androidx.core:core:1.6.0"
// Kotlin
force "androidx.core:core-ktx:1.6.0"
}
}
and as you the problem is now in
androidx.appcompat:appcompat:1.4.0-alpha
so I checked the gradle dependencies, yes , even I used
androidx.appcompat:appcompat:1.3.1
but my project shows the version is 1.4.0-alpha. here is my solution
configurations.all {
resolutionStrategy.eachDependency { details ->
def requested = details.requested
if (requested.group == "androidx.appcompat") {
if (requested.name == "appcompat") {
details.useVersion "1.3.1"
}
}
}
}
and it worked, now my project can build and run correctly, thank you, sir!
Obveiously the problem is now in androidx.appcompat:appcompat:1.4.0-alpha. If your UI use Toolbar, you will get the MenuHost not found crash.BUT, evenif I use resolutionStrategy to force 'androidx.appcompat:appcompat:1.3.1', dependency still make it toandroidx.appcompat:appcompat:{strictly 1.4.0-beta01}
It still confuse me a lot.
SOLVED -- someone write a update code for appcompat before... now it can force to 1.3.1 and solve the problem
change
implementation 'androidx.appcompat:appcompat:1.4.0'
to
implementation 'androidx.appcompat:appcompat:1.3.1'
that's it
implementation 'androidx.appcompat:appcompat:1.4.1'
was causing the problem, going back to 1.3.1 worked.
implementation 'androidx.appcompat:appcompat:1.3.1'
ill update once I get an official solution.

RuntimeException: Unable to instantiate application com.company.app.Application: ClassNotFoundException

I've read a few answers on this site with the same or similar error messages, and I've tried all the solutions already. Sadly, none of them have worked so far.
My gradle files all look like they're properly set up for Multidex, the Application class extends MultiDexApplication and is referenced correctly in the manifest, I've cleaned all caches and restarted the IDE, deleting builds from the project and the device and re-building/re-installing, etc. etc.
Inspecting the APK, I found the Application in classes2.dex, correctly referencing .super Landroidx/multidex/MultiDexApplication;
The stack I'm getting is like this:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.<REDACTED>, PID: 25475
java.lang.RuntimeException: Unable to instantiate application com.<REDACTED>.Application: java.lang.ClassNotFoundException: Didn't find class "com.<REDACTED>.Application" on path: DexPathList[[zip file "/data/app/~~b-NK-x066lFdY_bh0tm6ew==/com.<REDACTED>-V2WCXZvYqUZRGKbFMfmgFg==/base.apk"],nativeLibraryDirectories=[/data/app/~~b-NK-x066lFdY_bh0tm6ew==/com.<REDACTED>-V2WCXZvYqUZRGKbFMfmgFg==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1306)
at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7401)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7374)
at android.app.ActivityThread.access$1500(ActivityThread.java:301)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2118)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8425)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.<REDACTED>.Application" on path: DexPathList[[zip file "/data/app/~~b-NK-x066lFdY_bh0tm6ew==/com.<REDACTED>-V2WCXZvYqUZRGKbFMfmgFg==/base.apk"],nativeLibraryDirectories=[/data/app/~~b-NK-x066lFdY_bh0tm6ew==/com.<REDACTED>-V2WCXZvYqUZRGKbFMfmgFg==/lib/arm64, /system/lib64, /system/system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:76)
at android.app.Instrumentation.newApplication(Instrumentation.java:1158)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1298)
at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7401) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7374) 
at android.app.ActivityThread.access$1500(ActivityThread.java:301) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2118) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:246) 
at android.app.ActivityThread.main(ActivityThread.java:8425) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:596) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) 
Suppressed: java.io.IOException: Failed to open dex files from /data/app/~~b-NK-x066lFdY_bh0tm6ew==/com.<REDACTED>-V2WCXZvYqUZRGKbFMfmgFg==/base.apk because: Failure to verify dex file '/data/app/~~b-NK-x066lFdY_bh0tm6ew==/com.<REDACTED>-V2WCXZvYqUZRGKbFMfmgFg==/base.apk': Bad index for method_handle_item method_idx: ffff >= de57
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:367)
at dalvik.system.DexFile.<init>(DexFile.java:109)
at dalvik.system.DexFile.<init>(DexFile.java:82)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:439)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:398)
at dalvik.system.DexPathList.<init>(DexPathList.java:166)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:129)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:104)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:74)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:87)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:116)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:114)
at android.app.ApplicationLoaders.getClassLoaderWithSharedLibraries(ApplicationLoaders.java:60)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:933)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:990)
at android.app.LoadedApk.getResources(LoadedApk.java:1234)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2788)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2780)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7263)
... 8 more
Can anyone figure out what this is all about?
In the module level build.gradle, we added these lines:
// Near the top
apply plugin: 'com.google.firebase.crashlytics'
// ...
android {
// ...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
// ...
}
// ...
I have no idea how this fixed this crash, but I suppose that's what I get for using "It just works" libraries.

Problems getting started with Chirp SDKs for Android

I have downloaded SDK for Android from
https://developers.chirp.io/downloads
After that I added *.aar library as was explain here:
https://developer.android.com/studio/projects/android-library.html#AddDependency
Hurrah. I can build the project.
Now I want to install the test App on the phone. But the application crashes like this:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.chirp.sdkdemoapp, PID: 12979
java.lang.NoClassDefFoundError: Failed resolution of: Lkotlin/jvm/internal/Intrinsics;
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:2)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:5)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:8)
at io.chirp.sdkdemoapp.MainActivity.onCreate(MainActivity.java:77)
As I understand it, a problem arose with dependencies when packaging * aar
So I added in build.gradle (marked as Module) dependency for kotlin like:
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.2.61'
After that my ERROR has changed.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.chirp.sdkdemoapp, PID: 13395
java.lang.NoClassDefFoundError: Failed resolution of: Lokhttp3/MediaType;
at io.chirp.b.a.<init>(Unknown Source:24)
at io.chirp.chirpsdk.a.<init>(Unknown Source:36)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:20)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:5)
at io.chirp.chirpsdk.ChirpSDK.<init>(Unknown Source:8)
at io.chirp.sdkdemoapp.MainActivity.onCreate(MainActivity.java:77)
I have wrong paths to io.chirp internal libraries.
What should I do to resolve dependency related errors?
You have to import the okhttp 3.12.x dependency required by the ChirpSDK.
However, you don't need to explicitly import the dependency if you are using the SDK from the maven repository as this will be already included:
implementation 'io.chirp:chirpsdk:3.10.0'
and add the repository in your parent maven file:
repositories {
maven {
url "https://maven.chirp.io/release"
}
}
Thanks Dinu for your answer!
Maven repository doesn't work in my case (proxy issues or something else but this is the topic of another discussion).
The problem with using offline ChirpSDK was solved by adding two dependencies:
implementation 'com.squareup.okhttp3:okhttp:3.12.6'
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.50'

Fields from imported android library not generated in R file

I need to integrate a certain SDK with my app, I added the .aar file in my gradle dependencies and I added the code they provided me.
The gradle build went with no special problems, but when I tried to start the SDK's activity the app crashed with the following exception:
12-07 16:28:09.991 16236-16236/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.positiveapps.clickins, PID: 16236
java.lang.NoSuchFieldError: No static field action_show_neura of type I in class Lcom/neura/standalonesdk/R$id; or its superclasses (declaration of 'com.neura.standalonesdk.R$id' appears in /data/app/com.positiveapps.clickins-1/base.apk:classes2.dex)
at com.neura.dashboard.R$id.<clinit>(R.java:995)
at com.neura.dashboard.activity.LoginActivity.onCreate(LoginActivity.java:59)
at com.neura.dashboard.activity.AppAuthenticationActivity.onCreate(AppAuthenticationActivity.java:26)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
After I went through the R files that are generated in my application I found out a significant amount of fields that exist in R.txt file in the aar are missing from the generated R.
I've tried building with and without proguard, updating gradle version, I cleaning and rebuilding the project, removing "build" directory manually, adding the aar as a module.
None of these seem to be the problem, the R file is still missing fields.
Thanks for any help, Ilia.
Keep aar file in libs folder. ( as libname.aar )
then in app build.gradle specify following.
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
compile(name:'libname', ext:'aar')
}
and click sync project with gradle files.
Then clean build the project.

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

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:
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)
 
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"
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 :)
I had the same error.
I solved it by cleaning the project ( Build > Clean Project )
Just go to Android Studio menu - Build --> Rebuild Project.
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)...
Changing to
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
fixed issue
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.
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.
If you don't want to disable Instant Run, just do a project clean and rerun.
Change classpath 'com.android.tools.build:gradle:2.1.2' to classpath 'com.android.tools.build:gradle:2.1.0' fixes my problem.
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 ) .
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
}
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.
I just needed to reboot my device. Tried everything else first unfortunately so wasted hours.
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.
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.
No need to disable "instant run".
go to project's root using File Explorer
Finish Android Studio(AS)
delete(relocate somewhere) ".gradle" 's folder content
(to clean some cashs and old artifacts)
in res folder clean off all inappropriate files
launch the AS again
in module's build.gradle set buildTypes { debug {minifyEnabled true to false
(that looks like an error was in my proguard file)
Sync, compile and run the app again.
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.

Categories

Resources