Unable to get provider - rarely crash on kitkat - android

Few times in the week i receive crash report in GP console:
java.lang.RuntimeException: Unable to get provider mypackage.MyProvider: java.lang.ClassNotFoundException: Didn't find class "mypackage.MyProvider" on path: DexPathList[[zip file "/mnt/asec/mypackage-1/pkg.apk"],nativeLibraryDirectories=[/mnt/asec/mypackage-1/lib, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5018)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4589)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4522)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1381)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.ClassNotFoundException: Didn't find class "mypackage.MyProvider" on path: DexPathList[[zip file "/mnt/asec/mypackage-1/pkg.apk"],nativeLibraryDirectories=[/mnt/asec/mypackage-1/lib, /vendor/lib, /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.ActivityThread.installProvider(ActivityThread.java:5003)
... 12 more
Suppressed: java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFileNative(DexFile.java)
at dalvik.system.DexFile.openDexFile(DexFile.java:296)
at dalvik.system.DexFile.<init>(DexFile.java:80)
at dalvik.system.DexFile.<init>(DexFile.java:59)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:263)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:230)
at dalvik.system.DexPathList.<init>(DexPathList.java:112)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:57)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:326)
at android.app.LoadedApk.makeApplication(LoadedApk.java:508)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4514)
... 10 more
Also, after adding Firebase features to my project i start to receive same crash reports about com.google.firebase.provider.FirebaseInitProvider.
According to reports, this errors happens only on:
Android 4.4 98,7 %
Android 4.2 1,3 %
I've try all this ClassNotFoundException for a ContentProvider, but no result.
Is this really a system bug and every developer deals with it, or it's my error? I really want to stop annoying users. Thanks.

Your case really looks like bug described there in Android's Issue Tracker.
There you got issue when user starting app immediately after apk update.
There is workaround from comments which could help you to prevent this bug:
public class DevToolsApplication extends Application {
private static final String TAG = "DevToolsApplication";
#Override
public void onCreate() {
super.onCreate();
AppLogger.i(TAG, "app start...");
checkAppReplacingState();
}
private void checkAppReplacingState() {
if (getResources() == null) {
AppLogger.w(TAG, "app is replacing...kill");
Process.killProcess(Process.myPid());
}
}
}

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.

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.

[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 get provider com.google.firebase.provider.FirebaseInitProvider:

Unable to get provider com.google.firebase.provider.FirebaseInitProvider: to run the project due to this error . How do I go about it? Please help.
10-08 15:05:05.957 17562-17562/com.coretec.msacco E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.coretec.msacco, PID: 17562
java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.coretec.msacco-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.coretec.msacco-2, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:5055)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4626)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4566)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5336)
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:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/data/app/com.coretec.msacco-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.coretec.msacco-2, /vendor/lib, /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.ActivityThread.installProvider(ActivityThread.java:5040)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4626) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4566) 
at android.app.ActivityThread.access$1500(ActivityThread.java:151) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402) 
at android.os.Handler.dispatchMessage(Handler.java:110) 
at android.os.Looper.loop(Looper.java:193) 
at android.app.ActivityThread.main(ActivityThread.java:5336) 
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:828) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644) 
at dalvik.system.NativeStart.main(Native Method) 
Avoid using play-services as whole in your gradle file.
compile 'com.google.android.gms:play-services:9.8.0'
instead use specific ones
compile 'com.google.android.gms:play-services-location:9.8.0'
Configure your app for multidex
Modify the module-level build.gradle file to enable multidex and add the multidex library as a dependency, as shown here:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation "androidx.multidex:multidex:2.0.1"
}
Depending on whether you override the Application class, perform one of the following:
If you do not override the Application class, edit your manifest file to set android:name in the tag as follows:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="androidx.multidex.MultiDexApplication" >
...
</application>
</manifest>
If you do override the Application class, change it to extend MultiDexApplication (if possible) as follows:
public class MyApplication extends MultiDexApplication { ... }
Or if you do override the Application class but it's not possible to change the base class, then you can instead override the attachBaseContext() method and callMultiDex.install(this) to enable multidex:
> public class MyApplication extends SomeOtherApplication { #Override
> protected void attachBaseContext(Context base) {
> super.attachBaseContext(base);
> MultiDex.install(this); } }
Caution: Do not execute MultiDex.install() or any other code through reflection or JNI before MultiDex.install() is complete. Multidex tracing will not follow those calls, causing ClassNotFoundException or verify errors due to a bad class partition between DEX files.
source

Duplicated Play Store app fails to instantiate

Compiled an APK and tested it successfully on my device, tried it through the Google Play Store and it stops working immediately. This app is a copy of an existing app, since you cannot have the same package name twice I simply renamed the package name in the AndroidManifest.xml, compiled it, tested it and then uploaded it to the Play Store.
I do not understand why the app works when I copy it to a device but the same app fails when loaded through the Play Store. I generated a crash report which I accessed from the Play Store Developer Console. If anyone has experience of successfully duplicating apps on the Store then your help would be appreciated.
java.lang.RuntimeException: Unable to instantiate application de.schildbach.wallet.artbyte.WalletApplication: java.lang.ClassNotFoundException: Didn't find class "de.schildbach.wallet.artbyte.WalletApplication" on path: DexPathList[[zip file "/data/app/de.schildbach.wallet.artbyte-1/base.apk"],nativeLibraryDirectories=[/data/app/de.schildbach.wallet.artbyte-1/lib/arm, /data/app/de.schildbach.wallet.artbyte-1/base.apk!/lib/armeabi, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:680)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6395)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "de.schildbach.wallet.artbyte.WalletApplication" on path: DexPathList[[zip file "/data/app/de.schildbach.wallet.artbyte-1/base.apk"],nativeLibraryDirectories=[/data/app/de.schildbach.wallet.artbyte-1/lib/arm, /data/app/de.schildbach.wallet.artbyte-1/base.apk!/lib/armeabi, /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 android.app.Instrumentation.newApplication(Instrumentation.java:1005)
at android.app.LoadedApk.makeApplication(LoadedApk.java:670)
... 9 more
Suppressed: java.lang.ClassNotFoundException: de.schildbach.wallet.artbyte.WalletApplication
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)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
The Exception says that build is failed due to class not found on dex path list. Build the apk by cleaning the project and also recompile the native code using the ndk-build command. Then try it on the local device and then upload to play store.
The package name in AndroidManifest.xml is often also used for the code base, e.g. as class name of the activities. If you only rename the package name but leave the Java/dex code unchanged Android will not be able to find some classes as you already have noticed.
Check the AndroidManifest.xml for package relative class names (those that start with a .) and prepend the old package name:
Example
Old package name: org.example.myapp
Old activity name: <activity android:name=".MyActivity" ..>
New package name: com.example.newappname
New activity name: <activity android:name="org.example.myapp.MyActivity" ..>

Categories

Resources