Android Question Google Analytics Error : noSuchMethod: SharedPreferences$Editor.apply

jmon

Well-Known Member
Licensed User
Hello,

I recently got this error on some devices, for example on devices running Android 2.2.
B4X:
** Activity (main) Create, isFirst = true **

java.lang.NoSuchMethodError: android.content.SharedPreferences$Editor.apply

    at com.google.android.gms.analytics.internal.zzah$zza.zzaS(Unknown Source)
    at com.google.android.gms.analytics.internal.zzae.zzb(Unknown Source)
    at com.google.android.gms.analytics.internal.zzae.zza(Unknown Source)
    at com.google.android.gms.analytics.internal.zzc.zza(Unknown Source)
    at com.google.android.gms.analytics.internal.zzc.zzaI(Unknown Source)
    at com.google.android.gms.analytics.internal.zzk.zzhr(Unknown Source)
    at com.google.android.gms.analytics.internal.zzk.start(Unknown Source)
    at com.google.android.gms.analytics.internal.zzb.start(Unknown Source)
    at com.google.android.gms.analytics.internal.zze.<init>(Unknown Source)
    at com.google.android.gms.analytics.internal.zze.zzJ(Unknown Source)
    at com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source)
    at anywheresoftware.b4a.objects.AnalyticsTracker.Initialize(AnalyticsTracker.java:32)

    at com.xxxx.xxxx.main._activity_create(main.java:615)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at com.xxxx.xxxx.main.afterFirstLayout(main.java:100)
    at com.xxxx.xxxx.main.access$100(main.java:17)
    at com.xxxx.xxxx.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:144)
    at android.app.ActivityThread.main(ActivityThread.java:4937)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)
I use the Google Analytics v4 library. I've read and understood the problem from here : https://stackoverflow.com/questions/10491301/android-shared-preferences-crashes-on-some-devices
but how can I implement the solution provided in B4A?

Regards.
Jmon
 
Top