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

Discussion in 'Android Questions' started by jmon, May 7, 2015.

  1. jmon

    jmon Well-Known Member Licensed User

    Hello,

    I recently got this error on some devices, for example on devices running Android 2.2.
    Code:
    ** 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
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You cannot change this call as it happens inside Google Analytics SDK. I don't see it mentioned in Google's documentation but it seems like the minimum version of this library is Android 2.3.

    You can disable this feature based on the device version.
     
    jmon likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice