Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication ?Android - 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.

Related

Android app not working on android 6 (marshmallow) but working on other android versions classNotFoundException

I am trying to make an HTTP call to a server to get its HTML contents everything is working fine on other android versions. But in android 6 when the app is calling HTMLunit it crashes.
I know it has to do with something that works on API above 23. but not on the 23.. I tried many things but I sill can't fix it...
Why it's important to run the app on android 6:
A big number of my users is using android 6 and 5
The error:
FATAL EXCEPTION: Thread-9255
Process: bd.maruf.myapplication, PID: 7773
java.lang.NoClassDefFoundError: java.util.function.Supplier
at libcore.reflect.InternalNames.getClass(InternalNames.java:55)
at java.lang.Class.getDexCacheType(Class.java:476)
at java.lang.reflect.Method.getReturnType(Method.java:183)
at java.lang.Class.getDeclaredMethods(Class.java:678)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.process(AbstractJavaScriptConfiguration.java:212)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.getClassConfiguration(AbstractJavaScriptConfiguration.java:193)
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.<init>(AbstractJavaScriptConfiguration.java:67)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.<init>(JavaScriptConfiguration.java:685)
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getInstance(JavaScriptConfiguration.java:701)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.<init>(JavaScriptEngine.java:161)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:326)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:275)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:265)
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:257)
at bd.maruf.myapplication.MainActivity.main(MainActivity.kt:32)
at bd.maruf.myapplication.MainActivity.onCreate$lambda$1$lambda$0(MainActivity.kt:22)
at bd.maruf.myapplication.MainActivity.$r8$lambda$VtPJx1mT1BVGpp5vWQWqcx_e4kM(MainActivity.kt)
at bd.maruf.myapplication.MainActivity$$ExternalSyntheticLambda2.run(D8$$SyntheticClass)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class "java.util.function.Supplier" on path: DexPathList[[zip file "/data/app/bd.maruf.myapplication-1/base.apk"],nativeLibraryDirectories=[/data/app/bd.maruf.myapplication-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at libcore.reflect.InternalNames.getClass(InternalNames.java:53)
at java.lang.Class.getDexCacheType(Class.java:476) 
at java.lang.reflect.Method.getReturnType(Method.java:183) 
at java.lang.Class.getDeclaredMethods(Class.java:678) 
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.process(AbstractJavaScriptConfiguration.java:212) 
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.getClassConfiguration(AbstractJavaScriptConfiguration.java:193) 
at com.gargoylesoftware.htmlunit.javascript.configuration.AbstractJavaScriptConfiguration.<init>(AbstractJavaScriptConfiguration.java:67) 
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.<init>(JavaScriptConfiguration.java:685) 
at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getInstance(JavaScriptConfiguration.java:701) 
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.<init>(JavaScriptEngine.java:161) 
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:326) 
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:275) 
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:265) 
at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:257) 
at bd.maruf.myapplication.MainActivity.main(MainActivity.kt:32) 
at bd.maruf.myapplication.MainActivity.onCreate$lambda$1$lambda$0(MainActivity.kt:22) 
at bd.maruf.myapplication.MainActivity.$r8$lambda$VtPJx1mT1BVGpp5vWQWqcx_e4kM(MainActivity.kt) 
at bd.maruf.myapplication.MainActivity$$ExternalSyntheticLambda2.run(D8$$SyntheticClass) 
at java.lang.Thread.run(Thread.java:818) 
Suppressed: java.lang.ClassNotFoundException: java.util.function.Supplier
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 20 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
2022-11-12 18:11:50.861 7773-7807 Surface bd.maruf.myapplication D Surface::disconnect(this=0xaddb7b00,api=1)
what I have tried :
cleaning and rebuilding that project
adding:
defaultConfig { multiDexEnabled true}
dependencies {implementation 'com.android.support:multidex:1.0.3'
3. deleting .gradel and .idea file
java.util.function.Supplier is documented as "Added in API level 24", hence code requiring it will not work on pre 24 SDK due to class absence.
Will try to solve this in HtmlUnit - check https://github.com/HtmlUnit/htmlunit-android/issues/9 or https://twitter.com/htmlunit for progress.
After some analysis and experiments i decide to not fix this. The js engine (Rhino) uses classes from the java.util.function package. Changing this is not a simple task and there are many other thinks to do.
So sorry, but i like to stay with android 7 as minimum requirement.

Facebook Account Kit Collision with Google play services gradle

After configuring account kit sdk as
compile 'com.facebook.android:account-kit-sdk:4.+'
and gradle sync it conflict with com.google.android.gms gradle as mixing versions can lead to runtime crashes and my app crash as
Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at ...
the above error is due to mixing google play services gradle (I think Google play services gradle may be used by Facebook Account Kit SDK) because I have same version for all Google play services gradles.
And one more crash is coming from Facebook Account Kit SDK side as
java.lang.RuntimeException: Unable to get provider com.facebook.accountkit.internal.AccountKitInitProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
at android.app.ActivityThread.installProvider(ActivityThread.java:5260)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4808)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4748)
at android.app.ActivityThread.access$1700(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
at com.facebook.accountkit.internal.Initializer.initialize(Initializer.java:99)
at com.facebook.accountkit.internal.AccountKitController.initialize(AccountKitController.java:592)
at com.facebook.accountkit.internal.AccountKitInitProvider.onCreate(AccountKitInitProvider.java:31)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1758)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1733)
at android.app.ActivityThread.installProvider(ActivityThread.java:5257)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4808) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4748) 
at android.app.ActivityThread.access$1700(ActivityThread.java:153) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:5529) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 
But after removing
compile 'com.facebook.android:account-kit-sdk:4.+'
my app working without any issue.
But to integrate Facebook Account Kit in my app I have to include above gradle which conflict with google play services.
Totally disappointed, please help.
After upgrading Firebase Gradle as
compile 'com.google.firebase:firebase-messaging:11.6.0'
its not colliding but still gives above RuntimeException from Account Kit SDK.
To fix this you can do something like the following
compile ('com.facebook.android:account-kit-sdk:4.27.0') {
exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
exclude group: 'com.google.android.gms', module: 'play-services-auth'
}
compile 'com.google.android.gms:play-services-auth:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
That would remove the stale support gms library from Facebook's SDK and then swap in the same version of the lib that Firebase is using.
Possibly the conflict of libraries can be the reason. See dependencies here;
https://mvnrepository.com/artifact/com.facebook.android/account-kit-sdk/4.27.0
See if you could submit an issue with the facebook to update it.
Or if you need facebook for authentication only, you can use Facebook Android Sdk
What feature/service from firebase r u using , can u pls share the snippet of ur gradle dependencies for the same to better understand the problem here?
For Unable to get provider RuntimeException exception it seems that, Application is not initialized first, Content Providers are initialized before it.
And in Facebook account kit SDK's code it was trying to get my application context.
Now the problem was, I did implement method getApplicationContext() in application class that is getting application shared variable but that variable was setting globally and Facebook Account Kit sdk code getting Null application context.
Solution : setting shared variable in onCreate method instead of setting globally it resolved the problem of Unable to get provider.
And For Mixing issue, Account Kit SDK use 11.0.1 version for play services gradle and in my project I am having 11.0.4 that is actually not the issue because on compile time gradle takes latest gradle but In my project I am not referring below gradle which Facebook Account Kit SDK is using.
compile 'com.google.android.gms:play-services-auth-api-phone:11.0.1'
Solution : I have added above gradle with version 11.0.4 and the mixing gradle issue has been resolved.
compile 'com.google.android.gms:play-services-auth-api-phone:11.0.4'
And as suggested by #astryk if I exclude play-services-auth-api-phone module then gradle mixing error is not showing but it is not including that module becasue in AccountKitActivity on next button click my application crashes as
Crash Report Thread:main Exception:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/auth/api/phone/SmsRetriever;
at com.facebook.accountkit.internal.PhoneLoginController.createSmsToken(PhoneLoginController.java:250)
at com.facebook.accountkit.internal.PhoneLoginController.logIn(PhoneLoginController.java:188)
at com.facebook.accountkit.internal.LoginManager.logInWithPhoneNumber(LoginManager.java:372)
at com.facebook.accountkit.internal.AccountKitController.logInWithPhoneNumber(AccountKitController.java:631)
at com.facebook.accountkit.ui.PhoneLoginFlowManager.logInWithPhoneNumber(PhoneLoginFlowManager.java:57)
at com.facebook.accountkit.ui.ActivityPhoneHandler.onPhoneLoginComplete(ActivityPhoneHandler.java:189)
at com.facebook.accountkit.ui.AccountKitActivity$1.onReceive(AccountKitActivity.java:176)
at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:5529)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.api.phone.SmsRetriever" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappList item -1/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 16 more
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.auth.api.phone.SmsRetriever
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available`

[Android Studio]java.lang.RuntimeException: Unable to instantiate activity ComponentInfo java.lang.ClassNotFoundException: on path: DexPathList

I'm having an app and which works in android Lollipop and above, if I installed the app in android Kitkat device, the application crashes and show the error as below:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.SplashActivity}: java.lang.ClassNotFoundException: Didn't find class "com.SplashActivity" on path: DexPathList[[zip file "/data/app/com.partner-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.partner-1, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2131)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5146)
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:732)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.SplashActivity" on path: DexPathList[[zip file "/data/app/com.partner-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.partner-1, /system/lib]]
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 android.app.Instrumentation.newActivity(Instrumentation.java:1061)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2122)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2271) 
at android.app.ActivityThread.access$800(ActivityThread.java:144) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1205) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5146) 
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:732) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566) 
at dalvik.system.NativeStart.main(Native Method) 
I tried a lot and was not able to fix it, most of the answers are for eclipse projects.
The reason for api 21 on is:
Android 5.0 (API level 21) and higher uses a runtime called ART which natively supports loading multiple DEX files from APK files. ART performs pre-compilation at app install time which scans for classesN.dex files and compiles them into a single .oat file for execution by the Android device. Therefore, if your minSdkVersion is 21 or higher, you do not need the multidex support library.
From this guide: https://developer.android.com/studio/build/multidex.html
I solved the class not found error by naming my classes like this:
[Activity(Name = "somepackage.custombuttonrenderer")]
public class CustomButtonRenderer: ButtonRenderer
{ }
Here is my answer: Why is my custom ButtonRenderer not working?
Update you app level build.gradle file:
implementation 'com.android.support:multidex:1.0.0'
And update you application class with :
#Override
public void onCreate() {
super.onCreate();
MultiDex.install(this);
}
This worked to me:
Add this in your APLICATION class.
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(getBaseContext());
}
Explanation:
Android app (APK) files contain executable bytecode files in the form of Dalvik Executable (DEX) files, which contain the compiled code used to run your app. The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536
Versions of the platform prior to Android 5.0 (API level 21) use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can add the multidex support

Unable to instantiate application - java.lang.ClassNotFoundException: Didn't find class "com.xxxxx.App" on path: /data/app/com.xxxxx-1.apk

This is the error everytime I run the app:
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate application com.xxxxx.App: java.lang.ClassNotFoundException: Didn't find class "com.xxxxx.App" on path: /data/app/com.xxxxx-1.apk
at android.app.LoadedApk.makeApplication(LoadedApk.java:509)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4657)
at android.app.ActivityThread.access$1400(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxxxx.App" on path: /data/app/com.xxxxx-1.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:64)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newApplication(Instrumentation.java:992)
at android.app.LoadedApk.makeApplication(LoadedApk.java:504)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4657) 
at android.app.ActivityThread.access$1400(ActivityThread.java:159) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:176) 
at android.app.ActivityThread.main(ActivityThread.java:5419) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:525) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862) 
at dalvik.system.NativeStart.main(Native Method)
Here some info:
JavaVersion.VERSION_1_8 (I cannot use 1.7 because of a library)
buildToolsVersion '24.0.0'
compileSdkVersion & target 24 (also tried 23)
gradle 2.2.0-alpha4 (also tried with 2.1.0)
I have instant run disabled.
I have a class named App that extends Application, so in AndroidManifest.xml I have <application android:name="com.xxxxx.App"
Please don't mark this question as duplicate, because I have already tried all the solutions given, but I cannot get rid of this error.
 
I was having the same error and just cleaning the project solve it for me.
it seems a bug in the new version of android studio.
remove the app from your mobile phone then build => clean project and try installing again
Have you tried running the app on another device/emulator?
I experienced this problem once because I was the 2nd user on the device that I was trying to run it on. If that's the case, you will have to switch to the primary user(owner) every time you wish to run your app.
I was having the same issue, then tried creating the same application class in java instead of kotlin and it worked.

File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016 [duplicate]

This question already has answers here:
Update Android Support Library to 23.2.0 cause error: XmlPullParserException Binary XML file line #17<vector> tag requires viewportWidth > 0
(31 answers)
Closed 6 years ago.
Recently android support library was updated to 23.2.0. After downloading android sdk and updating android design support library into 23.2.0, this error happens repeatedly. My project can't even be compiled. The complete error log says:
03-02 12:00:04.945 9324-9324/com.creditease.zhiwang.debug E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.creditease.zhiwang.debug/com.creditease.zhiwang.activity.TabContainerActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
at android.app.ActivityThread.access$700(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1330)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5528)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
at android.content.res.Resources.loadDrawable(Resources.java:2974)
at android.content.res.Resources.getDrawable(Resources.java:1558)
at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:184)
at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:91)
at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar.java:74)
at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:210)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:119)
at com.creditease.zhiwang.activity.BaseActivity.initToolBar(BaseActivity.java:300)
at com.creditease.zhiwang.activity.BaseActivity.initToolBar(BaseActivity.java:265)
at com.creditease.zhiwang.activity.TabContainerActivity.onCreate(TabContainerActivity.java:107)
at android.app.Activity.performCreate(Activity.java:5372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
at android.app.ActivityThread.access$700(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1330)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5528)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
at dalvik.system.NativeStart.main(Native Method)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:933)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:873)
at android.content.res.Resources.loadDrawable(Resources.java:2970)
at android.content.res.Resources.getDrawable(Resources.java:1558)
at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:184)
at android.support.v7.widget.ToolbarWidgetWrapper.<init>(ToolbarWidgetWrapper.java:91)
at android.support.v7.app.ToolbarActionBar.<init>(ToolbarActionBar.java:74)
at android.support.v7.app.AppCompatDelegateImplV7.setSupportActionBar(AppCompatDelegateImplV7.java:210)
at android.support.v7.app.AppCompatActivity.setSupportActionBar(AppCompatActivity.java:119)
at com.creditease.zhiwang.activity.BaseActivity.initToolBar(BaseActivity.java:300)
at com.creditease.zhiwang.activity.BaseActivity.initToolBar(BaseActivity.java:265)
at com.creditease.zhiwang.activity.TabContainerActivity.onCreate(TabContainerActivity.java:107)
at android.app.Activity.performCreate(Activity.java:5372)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2271)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
at android.app.ActivityThread.access$700(ActivityThread.java:169)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1330)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5528)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
at dalvik.system.NativeStart.main(Native Method)
This error was thrown by setSupportActionBar(toolbar); whereas it didn't happen at 23.0.1 of android design library 23.2.0. Meanwhile according this log, I guessed this drawable was removed since android design library 23.2.0.
So, could someone told me why is this happening?
I think you need to make changes in your gradle.
// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
You’ll note this new attribute only exists in the version 2.0 of the Gradle Plugin. If you are using Gradle 1.5 you’ll instead use
// Gradle Plugin 1.5
android {
defaultConfig {
// Stops the Gradle plugin's automatic rasterization of vectors
generatedDensities = []
}
// Flag to tell aapt to keep the attribute ids around
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
I found similar question here.
See Support Vector Drawables and Animated Vector Drawables in Android Support Library update.
I hope its help you.
As per as the documentation of Google's support library for 24.0.0, they have changed the vector drawable library to what it was before:
Added AppCompatDelegate.setCompatVectorFromResourcesEnabled() method to re-enable usage of vector drawables in DrawableContainer objects on devices running Android 4.4 (API level 19) and lower. See AppCompat v23.2 — Age of the vectors! for more information.
I faced the same issue and my SVG statelist drawables used in my project were working just fine till Marshmallow devices.
Later when I got the crash for the same in Android N, I realized that the svgs were a bit corrupted and contained characters like: � and this caused the crash.
But these were not reflected in Android Marshmallow and prior devices.
Make sure your vector drawable doesn't contain any of those characters as the way of parsing has been changed from the library 24.0.0. So vector drawables working fine till Marshmallow might not work in Nougat devices.
Hope this helps :)
I solve this problem by updating my support library from
'com.android.support:appcompat-v7:23.2.0'
'com.android.support:design:23.2.0'
to the same dependencies of 23.2.1.
When I met the problem, I had not made any changes in my module built by Android Studio.
So I was so confused then I tried to update android support library.
After updating, please remember to sync your build.gradle
I solved the issue as follows:
Try with changing styles.xml to
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
This is because if style requires ActionBar there are chances of not finding abc_back button but with no action bar problem is solved
This worked for me: Replace the com.android.support:design version in build.gradle with one that works. Find which version works by creating a new project from scratch in Android Studio and using the version from that.
I had this problem when I added a Navigation Drawer Activity from the File->New->Activity menu to an older project with Android Studio.
Android Studio added a dependency like so:
compile 'com.android.support:design:24.0.0-alpha1'
(I'm not sure of the exact version but it had '24' and 'alpha').
I then created a new dummy project, specifying a Navigation Drawer Activity in the new project wizard. I noticed that the new project had a different dependency: compile 'com.android.support:design:23.2.1'
So I took this dependency and put it in the first project, and the problem was solved.
Source - http://android-developers.blogspot.in/2016/02/android-support-library-232.html
when using AppCompat with ImageView (or subclasses such as ImageButton
and FloatingActionButton), you’ll be able to use the new app:srcCompat
attribute to reference vector drawables (as well as any other drawable
available to android:src):
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/ic_add" />
where you can define your app in your root element as
xmlns:app="http://schemas.android.com/apk/res-auto"
I've had this issue because my Manifest file had style that was defined only in v21 style. Not sure why it was pointing at this type of error but someone may find this helpful.

Categories

Resources