Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to instantiate receiver First run only

We have a game developed on Unity , we are using google analytics in the game , the game builds and runs smoothly with no errors at all

we uploaded the apk to Play Store for beta testing , the first time we run the app it crashes , the second time it works perfectly, and this happens for fresh installs only , users who update the game don't experiance this error .

We have the same behaviour on 5 Different devices with different android versions

I catched the error in the logcat , I'm fimiliar with this error and usually you will be missing a library or something , but the app works just fine on build , only fresh installs don't work!

I even downloaded the app from play store , pulled the apk to my PC , and installed the app again using adb , and it DOESN'T crash!

here are the logs for the error:

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

like image 698
Hassan Khallouf Avatar asked Jul 26 '16 06:07

Hassan Khallouf


1 Answers

I had encountered a similar issue by migrating my android project from Eclipse to Android Studio. The root cause for me was that even though Google Analytics library was included in the project, the google services library was missing for the project.

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

Primarily these steps:

The Google Services plugin for Gradle parses configuration information from the google-services.json file. Add the plugin to your project by updating your top-level build.gradle and your app-level build.gradle files as follows:

Add the dependency to your project-level build.gradle:

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

Add the plugin to the bottom of your app-level build.gradle:

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

Now, you need to add a dependency for Google Play Services. Inside your app's build.gradle add:

compile 'com.google.android.gms:play-services-analytics:9.2.0'
like image 140
marcwjj Avatar answered Oct 24 '22 09:10

marcwjj