Android Question Firebase Analytics crashing app in Service_Create

sdixon

Member
Licensed User
Longtime User
Didn't work for me, the app died when it hit service_create

copied everything from the previous post to the manifest file

B4X:
'************ Google Play Services Base ************
AddApplicationText(
   <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:exported="false"/>
    <meta-data
  android:name="com.google.android.gms.version"
  android:value="@integer/google_play_services_version" />
)
'************ Google Play Services Base (end) ************
'************ Firebase Base ************
CreateResourceFromFile("google-services", "google-services.json")
AddPermission(android.permission.ACCESS_NETWORK_STATE)
AddPermission(android.permission.INTERNET)
AddPermission(android.permission.WAKE_LOCK)
AddPermission(com.google.android.c2dm.permission.RECEIVE)
AddPermission(${applicationId}.permission.C2D_MESSAGE)
AddManifestText( <permission android:name="${applicationId}.permission.C2D_MESSAGE"
  android:protectionLevel="signature" />)
AddApplicationText(
<receiver
  android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
  android:enabled="true">
  <intent-filter>
  <action android:name="com.google.android.gms.measurement.UPLOAD"/>
  </intent-filter>
  </receiver>

  <service
  android:name="com.google.android.gms.measurement.AppMeasurementService"
  android:enabled="true"
  android:exported="false"/>
   <provider
  android:authorities="${applicationId}.firebaseinitprovider"
  android:name="com.google.firebase.provider.FirebaseInitProvider"
  android:exported="false"
  android:initOrder="100" />
    <receiver
  android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
  android:enabled="true">
  <intent-filter>
  <action android:name="com.google.android.gms.measurement.UPLOAD"/>
  </intent-filter>
  </receiver>

  <service
  android:name="com.google.android.gms.measurement.AppMeasurementService"
  android:enabled="true"
  android:exported="false"/>
   <receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver"
  android:exported="true"
  android:permission="com.google.android.c2dm.permission.SEND" >
  <intent-filter>
  <action android:name="com.google.android.c2dm.intent.RECEIVE" />
  <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
  <category android:name="${applicationId}" />
  </intent-filter>
  </receiver>
    <receiver
  android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver"
  android:exported="false" />


  <service
  android:name="com.google.firebase.iid.FirebaseInstanceIdService"
  android:exported="true">
  <intent-filter android:priority="-500">
  <action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
  </intent-filter>
  </service>
)
'************ Firebase Base (end) ************
'************ Firebase Analytics ************
AddApplicationText(
  <receiver
  android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
  android:enabled="true">
  <intent-filter>
  <action android:name="com.google.android.gms.measurement.UPLOAD"/>
  </intent-filter>
  </receiver>

  <service
  android:name="com.google.android.gms.measurement.AppMeasurementService"
  android:enabled="true"
  android:exported="false"/>

  <service android:name="com.google.firebase.crash.internal.service.FirebaseCrashReceiverService"
  android:process=":background_crash"/>

  <service android:name="com.google.firebase.crash.internal.service.FirebaseCrashSenderService"
  android:process=":background_crash"/>
)
'************ Firebase Analytics (end) ************
'************ Firebase Ads ************
AddApplicationText(
  <activity
  android:name="com.google.android.gms.ads.AdActivity"
  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
  android:theme="@android:style/Theme.Translucent" />
  <activity android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
  android:theme="@style/Theme.IAPTheme"/>
)
'************ Firebase Ads (end) ************

and here is the error messages

B4X:
** Service (starter) Create **
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/measurement/internal/zzx;
    at com.google.firebase.analytics.FirebaseAnalytics.getInstance(Unknown Source)
    at anywheresoftware.b4a.objects.FirebaseAnalyticsWrapper.Initialize(FirebaseAnalyticsWrapper.java:29)
    at com.unicornsystemz.totalbeautychat.starter._service_create(starter.java:210)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:153)
    at com.unicornsystemz.totalbeautychat.starter.onCreate(starter.java:54)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3808)
    at android.app.ActivityThread.access$2100(ActivityThread.java:222)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1883)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:158)
    at android.app.ActivityThread.main(ActivityThread.java:7229)
    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 "com.google.android.gms.measurement.internal.zzx" on path: DexPathList[[zip file "/data/app/com.unicornsystemz.totalbeautychat-1/base.apk"],nativeLibraryDirectories=[/data/app/com.unicornsystemz.totalbeautychat-1/lib/arm64, /vendor/lib64, /system/lib64]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
    ... 20 more
    Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.measurement.internal.zzx
        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)
        ... 21 more
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
 

sdixon

Member
Licensed User
Longtime User
Device name: Samsung Galaxy S7 edge
Model number: SM-G935F
Android 6.0.1
 
Upvote 0

sdixon

Member
Licensed User
Longtime User
Just tested it on my tablet and got the same story

GT-P5110
Android 4.2.2
 
Upvote 0

sdixon

Member
Licensed User
Longtime User
After further investigation it seemed that the following had crept into my code

B4X:
#ExcludeClasses: .games, .drive, .fitness, .wearable, .measurement, .cast, .auth, .nearby
#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .vision, .gcm

by removing the .measurement it now runs fine.

B4X:
#ExcludeClasses: .games, .drive, .fitness, .wearable, .cast, .auth, .nearby
#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .vision, .gcm

Nothing like excluding a class that you eventually need.

Thanks for your help.
 
Upvote 0

sdixon

Member
Licensed User
Longtime User
Thanks for the heads up!
 
Upvote 0
Top