Android Question StrictMode policy violation [...] Landroid/graphics/drawable/GradientDrawable$GradientState

FrankBerra

Active Member
Licensed User
Hello everyone.

I never took a in consideration Google Pre-Launch reports and now while i was looking at them i saw the following error:
B4X:
StrictMode policy violation: android.os.strictmode.NonSdkApiUsedViolation: Landroid/graphics/drawable/GradientDrawable$GradientState;->mSolidColors:Landroid/content/res/ColorStateList;
   at android.os.StrictMode.lambda$static$1(StrictMode.java:428)
   at android.os.-$$Lambda$StrictMode$lu9ekkHJ2HMz0jd3F8K8MnhenxQ.accept(Unknown Source:2)
   at java.lang.Class.getDeclaredField(Native Method)
   at anywheresoftware.b4a.objects.B4XViewWrapper.getColor(B4XViewWrapper.java:386)
   at polka.app.dotindicator._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv7(dotindicator.java:96)
   at polka.app.dotindicator._designercreateview(dotindicator.java:192)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
   at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:67)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
   at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
   at polka.app.main._precaricalayout_startup(main.java:12377)
   at polka.app.main._activity_create(main.java:931)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
   at polka.app.main.afterFirstLayout(main.java:117)
   at polka.app.main.access$000(main.java:30)
   at polka.app.main$WaitForLayout.run(main.java:95)
   at android.os.Handler.handleCallback(Handler.java:873)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:193)
   at android.app.ActivityThread.main(ActivityThread.java:6718)
   at java.lang.reflect.Method.invoke(Native Method)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
The indicated sub is:
B4X:
Sub AttivaUnCerchio(NumeroCerchio As Int)
   If NumeroCerchio <= ListaDeiCerchi.Size Then
       For z = 0 To ListaDeiCerchi.Size - 1
           Dim CerchioCheDisattivo As B4XView = ListaDeiCerchi.Get(z)
           CerchioCheDisattivo.SetColorAnimated(200, CerchioCheDisattivo.Color, ParametriIndicatore.Get("ColoreSfondo_Disattivo"))
       Next
          
       Dim CerchioDaAttivare As B4XView = ListaDeiCerchi.Get(NumeroCerchio - 1)
       CerchioDaAttivare.SetColorAnimated(200, ParametriIndicatore.Get("ColoreSfondo_Disattivo"), ParametriIndicatore.Get("ColoreSfondo_Attivo"))

   End If
End Sub
If i am not wrong, for me it seems it is related to CerchioCheDisattivo.Color.
Anyone has an advice on how to get the color of a B4XView (in this case a panel) without violating StrictMode policy?
 
Top