Failed to create receiver instance First start only

We have a game developed on Unity, we use Google Analytics in the game, the game builds and runs smoothly without errors at all

we downloaded apk to the Play Store for beta testing, the first time we launch the application, it crashes, the second time it works fine, and this only happens for fresh installations, users who update the game do not experience this error.

We have the same behavior on 5 different devices with different versions of Android

I caught an error in logcat, I know this error, and usually you will miss a library or something like that, but the application works fine when building, only fresh installations do not work!

I even downloaded the application from the game store, pulled apk to my computer and installed the application again using adb, and it DOES NOT crash!

Here are the error logs:

java.lang.Error: FATAL EXCEPTION [main] Unity version : 5.2.5f1 Device model : samsung GT-I9500 Device fingerprint: samsung/ja3gxx/ja3g:5.0.1/LRX22C/I9500XXUHOH6:user/release-keys Caused by: java.lang.RuntimeException: Unable to instantiate receiver com.google.android.gms.analytics.CampaignTrackingReceiver: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.analytics.CampaignTrackingReceiver" on path: DexPathList[[zip file "/data/app/com.remalit.kammelna-1/base.apk"],nativeLibraryDirectories=[/data/app/com.remalit.kammelna-1/lib/arm, /vendor/lib, /system/lib]] at android.app.ActivityThread.handleReceiver(ActivityThread.java:2974) at android.app.ActivityThread.access$1800(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1525) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5942) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.analytics.CampaignTrackingReceiver" on path: DexPathList[[zip file "/data/app/com.remalit.kammelna-1/base.apk"],nativeLibraryDirectories=[/data/app/com.remalit.kammelna-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 android.app.ActivityThread.handleReceiver(ActivityThread.java:2969) at android.app.ActivityThread.access$1800(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1525) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5942) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.analytics.CampaignTrackingReceiver 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) ... 11 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available 

07-26 09: 28: 55.991 3166-29939 /? E / android.os.Debug: ro.product_ship = true

+6
source share
1 answer

I ran into a similar problem by migrating my Android project from Eclipse to Android Studio. The main reason for me was that although the Google Analytics library was included in the project, the google project library was missing for the project.

I followed the setup of Google Analytics for android studio and fixed the problem: https://developers.google.com/analytics/devguides/collection/android/v4/

First of all, these steps:

The Google Services plugin for Gradle parses configuration information from google-services.json. Add the plugin to your project update the build.gradle assembly at the top level and create application-level build.gradle files as follows:

Add the dependency to your build.gradle project:

 classpath 'com.google.gms:google-services:3.0.0' 

Add the plugin to the bottom of your build level:

 apply plugin: 'com.google.gms.google-services' 

Now you need to add a dependency for Google Play services. inside your build.gradle application adds:

 compile 'com.google.android.gms:play-services-analytics:9.2.0' 
+1
source

All Articles