5

I have a Unity game deployed to Android.

In Google play console, I am seeing many crashes that happen on old Android versions (<=7.1). The crash is caused by a ClassNotFoundException, but the report does not show the class that is not found.

In the crashes console I get the following stack trace:

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:3025)
  at android.app.ActivityThread.-wrap18 (ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1565)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:179)
  at android.app.ActivityThread.main (ActivityThread.java:6152)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:886)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: 
  at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:380)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:3020)

Which is too generic and does not hint on what class is missing.

I was wondering if there is another way to find the missing class. I am using Multidex (I don't know if it's relative to the problem).

Any help will be appreciated here..

2 Answers 2

6

So I found the cause for the ClassNotFoundException, which was not the multidex configuration, but a Receiver that one of my plugins added to the manifest with a class that was not included in the project.

More important is how I have found it, this can help others.. it appears that Google play console does not show the entire exception data if it's a multiline message. I have installed Firebase Crashlytics, and within a few hours got the actual missing class.

Here is what you get in Google play console:

Caused by: java.lang.ClassNotFoundException: 
  at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:380)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:312)
  at android.app.ActivityThread.handleReceiver (ActivityThread.java:3049)

Here is what you get in Firebase Crashlytics:

Caused by java.lang.ClassNotFoundException
Didn't find class "com.mintegral.msdk.click.AppReceiver" on path: DexPathList[[zip file "/data/app/com.bbumgames.spadesroyale-1/base.apk", zip file "/data/app/com.bbumgames.spadesroyale-1/split_config.arm64_v8a.apk"],nativeLibraryDirectories=[/data/app/com.bbumgames.spadesroyale-1/lib/arm64, /data/app/com.bbumgames.spadesroyale-1/base.apk!/lib/arm64-v8a, /data/app/com.bbumgames.spadesroyale-1/split_config.arm64_v8a.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]

I am not sure why Google is not showing the second line, seems like a bug to me, but anyways, my problem is now solved.

Sign up to request clarification or add additional context in comments.

6 Comments

I have exactly the same problem, having ClassNotFoundException without class name in Google Play Console. So, based on your success, I integrated Crashlytics. Let's see tomorrow my Firebase console...
@Zotyi did Firebase show you the class that was missing?
@qwiboo I think so, but I can go back only 90 days in the crash log of Firebase Console, so cannot check which one
@Zotyi I don't really care about the actual class. I just want to know if Firebase Crashlytics actually really shows you more info from the logs than just the logs in google play console?
@qwiboo: Yes, much more verbose
|
0

It could be a multiplex issue. In your build.gradle (module-level) add the following if not already there:

android {
    defaultConfig {
        ...
        multiDexEnabled true
    }
    ...
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3’
}

If you don’t have an application class in your app add this to your manifest (within the application tag):

android:name="android.support.multidex.MultiDexApplication"

If you do, then add this:

public class MyApplication extends SomeOtherApplication {
      @Override
      protected void attachBaseContext(Context base) {
         super.attachBaseContext(base);
         MultiDex.install(this);
      }
    }

Read more about it here

3 Comments

Multidex is enabled, but only by adding the multiDexEnabled flag and not doing the other steps. I have read that if I target android versions greater than 20, this is the only steps needed (?). Maybe Unity does the rest.. appmediation.com/unity-enable-multidex Anyways, can Multidex be this exception's source?
@Ran your minSdkVersion needs to be higher than 20 in order for the above to be taken care of automatically, not your targetSdkVersion.
Ok, I will change my minSdkVersion. Not sure if this is the cause to the problem.. reading other posts it seems that the AndroidX library might be problematic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.