Home > Mobile >  AppWidget Crashes as soons as it loads
AppWidget Crashes as soons as it loads

Time:12-31

My widget service loads an image (bitmap) from webview and then sets it on the widget view. It is mostly working in most of the devices but on some devices, I recieve this error...

It's been few days, I'm scratching my head changing code but nothing works ... Please help me.. what's wrong

This is the error

`

D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/cr_Ime: updateState: type [0->1], flags [514], show [false], 
I/zygote: Background concurrent copying GC freed 100457(2MB) AllocSpace objects, 0(0B) LOS objects, 49% free, 2MB/5MB, paused 5.675ms total 29.498ms
    
    --------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: WebpageScreenshotService
    Process: com.mm.Widgets, PID: 5392
    java.lang.StackOverflowError: stack size 1038KB
        at java.lang.Class.isPrimitive(Unknown Source:0)
        at com.google.gson.internal.$Gson$Types.checkNotPrimitive($Gson$Types.java:434)
        at com.google.gson.internal.$Gson$Types.access$000($Gson$Types.java:43)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:551)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
E/AndroidRuntime:     at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
        at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553)
        at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111)
E/AndroidRuntime:     at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546)



E/AndroidRuntime:     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
        at com.google.gson.Gson.getAdapter(Gson.java:360)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
        at com.google.gson.Gson.getAdapter(Gson.java:360)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
        at com.google.gson.Gson.getAdapter(Gson.java:360)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
        at com.google.gson.Gson.getAdapter(Gson.java:360)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
        at com.google.gson.Gson.getAdapter(Gson.java:360)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
        at com.google.gson.Gson.getAdapter(Gson.java:360)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getFieldAdapter(ReflectiveTypeAdapterFactory.java:136)
E/AndroidRuntime:     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.access$100(ReflectiveTypeAdapterFactory.java:49)


E/AndroidRuntime:     at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.<init>(ReflectiveTypeAdapterFactory.java:106)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:105)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:161)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:97)
        at com.google.gson.Gson.getAdapter(Gson.java:360)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:55)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:113)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:240)
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.write(TypeAdapterRuntimeTypeWrapper.java:68)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.write(ReflectiveTypeAdapterFactory.java:113)
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.write(ReflectiveTypeAdapterFactory.java:240)
        at com.google.gson.Gson.toJson(Gson.java:605)
        at com.google.gson.Gson.toJson(Gson.java:584)
        at com.google.gson.Gson.toJson(Gson.java:539)
        at com.google.gson.Gson.toJson(Gson.java:519)
        at com.orhanobut.hawk.GsonParser.toJson(GsonParser.java:26)
        at com.orhanobut.hawk.HawkConverter.toString(HawkConverter.java:33)
        at com.orhanobut.hawk.DefaultHawkFacade.put(DefaultHawkFacade.java:33)
        at com.orhanobut.hawk.Hawk.put(Hawk.java:39)
        at com.mm.Widgets.Sp_Widgets.ScreenshotService$ServiceHandler$1.onPageFinished(ScreenshotService.java:142)
        at com.android.webview.chromium.WebViewContentsClientAdapter.onPageFinished(WebViewContentsClientAdapter.java:546)
        at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:201)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:164)
        at android.os.HandlerThread.run(HandlerThread.java:65)

`

CodePudding user response:

That is a long stack trace, but if you scan down far enough, you get past Gson and to other code:

        at com.google.gson.Gson.toJson(Gson.java:519)
        at com.orhanobut.hawk.GsonParser.toJson(GsonParser.java:26)
        at com.orhanobut.hawk.HawkConverter.toString(HawkConverter.java:33)
        at com.orhanobut.hawk.DefaultHawkFacade.put(DefaultHawkFacade.java:33)
        at com.orhanobut.hawk.Hawk.put(Hawk.java:39)
        at com.mm.Widgets.Sp_Widgets.ScreenshotService$ServiceHandler$1.onPageFinished(ScreenshotService.java:142)

I am assuming that com.mm.Widgets is your app. You appear to be using this Hawk library, and that is what is raising the exception. It uses Gson to persist something, and it is unhappy with what you are trying to persist. Either:

  • There is something specific to what you are passing to put() that Gson cannot handle, or
  • Hawk is just confused

Since Hawk does not appear to be actively maintained, I would strongly consider switching away from Hawk. Depending on what you are trying to store, SharedPreferences or Jetpack DataStore may work. For large amounts of complex data, consider a SQLite database via Room or SQLDelight.

  • Related