Android didn't find application class crash - android

In Manifest I declared
<application
android:name=com.example.App>
When the app starts, sometimes this crash happens:
java.lang.RuntimeException: Unable to instantiate application com.example.App: java.lang.ClassNotFoundException: Didn't find class "com.example.App" on path: DexPathList[[zip file "/mnt/asec/com.example.myapp-1/pkg.apk"],nativeLibraryDirectories=[/mnt/asec/com.example.myapp-1/lib, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4514)
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(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
Is it possible to fix it somehow?

This doesn't seems to be an app crash. This is just a verbose message raised when dalvik reinstall the apk.It won't occur on end-user's device.To fix it on your development machine, just clean and rebuild.

Related

Android NoClassDefFoundError on android 4.4.2

When I try to run my app on Android 4.4.2 it is giving me this error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.package, PID: 24775
java.lang.NoClassDefFoundError: my/package/models/Transaction
at java.lang.Class.getDeclaredFields(Native Method)
at java.lang.Class.getDeclaredFields(Class.java:610)
at com.activeandroid.util.ReflectionUtils.getDeclaredColumnFields(ReflectionUtils.java:73)
at com.activeandroid.TableInfo.<init>(TableInfo.java:66)
at com.activeandroid.ModelInfo.loadModelFromMetaData(ModelInfo.java:101)
at com.activeandroid.ModelInfo.<init>(ModelInfo.java:61)
at com.activeandroid.Cache.initialize(Cache.java:66)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:44)
at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:34)
at com.activeandroid.content.ContentProvider.onCreate(ContentProvider.java:39)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
at android.app.ActivityThread.installProvider(ActivityThread.java:5233)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
at android.app.ActivityThread.access$1600(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "my.package.models.Transaction" on path: DexPathList[[zip file "/data/app/my.package-1.apk"],nativeLibraryDirectories=[/data/app-lib/my.package-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
However, for Android 5.0 and above it is working without any errors.
What is the reason and how can I fix it?
Note: there is a similar question on StackOverflow but it does not have any answers.
You can find the answer for this question here:
NoClassDefFoundError with Android Studio on Android 4
https://developer.android.com/studio/build/multidex
Try this
Just go to disable Instant Run Go to
File -> Settings -> Build,Execution, Deployment -> Instant Run ->
Uncheck the checkbox for instant run
Run your app once.

java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider"

I Received a crash report on my developers console which I have some trouble figuring out. The crash is reported by a Android 4.4 device and it is reported with the recent update I published for my app. I've seen other topics here on Stackoverflow on the same issue but as far as I know all of them are with users that are exceding the 64k method limit. I Used the apk analyse tool in Android Studio and it states that my dex file contains around 29000 methods and 37000 references. Now I'm not sure if I need to add those numbers or if I only need to look at the 29000 method count to determine if I exceed the 64k limit. I did test the apk on a 4.4 emulator and I can install and run it without issue.
Can someone shed some light on this?
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:836)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.provider.FirebaseInitProvider" on path: DexPathList[[zip file "/mnt/asec2/[2]com.cubeactive.qnotelistfree-1/pkg.apk"],nativeLibraryDirectories=[/mnt/asec2/[2]com.cubeactive.qnotelistfree-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)
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:836)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
at dalvik.system.NativeStart.main(NativeStart.java)

Android Telegram app crash on specific devices

I have integrated Telegram in one of my apps.
Its working fine on many devices and Android version, but crashing on Android 4.4, Samsung Galaxy S3.
The error log that I am getting is:
org/telegram/SQLite/SQLitePreparedStatement
java.lang.Runtime.nativeLoad(Native Method)
java.lang.Runtime.doLoad(Runtime.java:421)
java.lang.Runtime.loadLibrary(Runtime.java:362)
java.lang.System.loadLibrary(System.java:526)
org.telegram.android.NativeLoader.initNativeLibs(NativeLoader.java:196)
org.telegram.messenger.ApplicationLoader.onCreate(ApplicationLoader.java:188)
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4368)
android.app.ActivityThread.access$1500(ActivityThread.java:138)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1296)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:149)
android.app.ActivityThread.main(ActivityThread.java:5045)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:515)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
dalvik.system.NativeStart.main(Native Method)
Caused by:
java.lang.ClassNotFoundException: Didn't find class "org.telegram.SQLite.SQLitePreparedStatement" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.bcd.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.bcd.app-1, /vendor/lib, /system/lib, /system/lib/arm]]
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
java.lang.ClassLoader.loadClass(ClassLoader.java:497)
java.lang.ClassLoader.loadClass(ClassLoader.java:457)
java.lang.Runtime.nativeLoad(Native Method)
java.lang.Runtime.doLoad(Runtime.java:421)
java.lang.Runtime.loadLibrary(Runtime.java:362)
java.lang.System.loadLibrary(System.java:526)
org.telegram.android.NativeLoader.initNativeLibs(NativeLoader.java:196)
Any help ?
Before all, as the above error seems, there's naming problem in the native source code and maybe it emanates from changing in package name of the project.
You should change package name in all native source code and then rebuild it.
Replace in path the two followings cases in jni folder:
Java_org_telegram_
org/telegram/
with the style of naming your packages, like the examples below:
Java_org_telegram_example_
org/telegram/example/
In the above example, the package name is:
org.telegram.example.messenger

java.lang.RuntimeException: Unable to instantiate application

In Google Play Developer Console I see this crash:
java.lang.RuntimeException: Unable to instantiate application com.example.MyApp: java.lang.ClassNotFoundException: Didn't find class "com.example.MyApp" on path: DexPathList[[zip file "/mnt/asec/com.example.testapp-1/pkg.apk"],nativeLibraryDirectories=[/mnt/asec/com.example.testapp-1/lib, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4545)
at android.app.ActivityThread.access$1500(ActivityThread.java:160)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1390)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5330)
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:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.MyApp" on path: DexPathList[[zip file "/mnt/asec/com.example.testapp-1/pkg.apk"],nativeLibraryDirectories=[/mnt/asec/com.example.testapp-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.Instrumentation.newApplication(Instrumentation.java:975)
at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
... 11 more
Suppressed: java.io.IOException: unable to open DEX file
at dalvik.system.DexFile.openDexFileNative(Native Method)
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)
... 11 more
This crash occurs mostly on Android versions 4.4 and 4.2.
This answer suggests that this crash occurs when the apk is updated by dalvik. It seems to be a low-priority Android bug.
Are there any workarounds for this?
Does it help to set
<application
android:allowBackup="false"
in Manifest.xml?
(Maybe the backup of application is stored on SD-card, which is causing the problem on apk update).
This error usually occurs when you declare a class extending Application (android.app.Application) and then user android:name="thatClassName"
But if your App can't access it class fully. This error can occur
Try Making the class public only
It will make the application user that class globally

Didn't find class "mono.android.app.Application"

My Xamarin Android app is already in production, people are downloading it from Google play and everything seems to be fine, except from time to time I get following errors in Google Play Developer Console :
java.lang.RuntimeException: Unable to instantiate application mono.android.app.Application: java.lang.ClassNotFoundException: Didn't find class "mono.android.app.Application" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib, /vendor/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:559)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5119)
at android.app.ActivityThread.access$1500(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1418)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5867)
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:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "mono.android.app.Application" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib, /vendor/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.newApplication(Instrumentation.java:982)
at android.app.LoadedApk.makeApplication(LoadedApk.java:550)
... 11 more
or similar but slightly different version:
java.lang.RuntimeException: Unable to instantiate application mono.android.app.Application: java.lang.ClassNotFoundException: Didn't find class "mono.android.app.Application" on path: /mnt/asec/myapp-1/pkg.apk
at android.app.LoadedApk.makeApplication(LoadedApk.java:504)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4563)
at android.app.ActivityThread.access$1400(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1349)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5317)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "mono.android.app.Application" on path: /mnt/asec/myapp-1/pkg.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newApplication(Instrumentation.java:985)
at android.app.LoadedApk.makeApplication(LoadedApk.java:499)
... 11 more
I've got zero google results for ClassNotFoundException + mono.android.app.Application. According to Developer console it comes from android 4.2 and 4.4., different devices (HTC, Samsung..), even from devices which i tested and everything works (HTC One).
Any ideas? Is this bug in mono? or Xamarin? Or am I doing something wrong?
Whenever xamarin app install in the device it is find to mono runtime support lib, if it is not installed in the device then it will stop to run so, if u have run without mono installation you can change some settings on:
Property => Android Option
Go to Packaging and select only one Bundle assemblies into native code, and also go to linker and select linking is None then run it.
I hope it might work.

Categories

Resources