android_sdk
android_sdk copied to clipboard
Fix IncorrectContextUse warning
When StrictMode is enabled, Android 11 or higher will display a warning if the app requests WindowManager on application contexts.
When trying to send event
E/ContextImpl: Tried to access visual service WindowManager from a non-visual Context:com.myApp@82752ca
Visual services, such as WindowManager, WallpaperService or LayoutInflater should be accessed from Activity
or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle),
which are adjusted to the configuration and visual bounds of an area on screen.
java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:com.myApp@82752ca
at android.app.ContextImpl.getSystemService(ContextImpl.java:1926)
at android.content.ContextWrapper.getSystemService(ContextWrapper.java:814)
at com.adjust.sdk.sig.NativeLibHelper.nSign(Native Method)
at com.adjust.sdk.sig.NativeLibHelper.sign(NativeLibHelper.java:15)
at com.adjust.sdk.sig.SignerInstance.sign(SignerInstance.java:112)
at com.adjust.sdk.sig.Signer.sign(Signer.java:74)
at java.lang.reflect.Method.invoke(Native Method)
at com.adjust.sdk.Reflection.invokeMethod(Unknown Source:8)
at com.adjust.sdk.Reflection.invokeInstanceMethod(Unknown Source:4)
at com.adjust.sdk.AdjustSigner.sign(Unknown Source:46)
at com.adjust.sdk.PackageBuilder.buildEventPackage(Unknown Source:36)
When tried to handle deeplink
E/ContextImpl: Tried to access visual service WindowManager from a non-visual Context:com.myApp@82752ca
Visual services, such as WindowManager, WallpaperService or LayoutInflater should be accessed from Activity
or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle),
which are adjusted to the configuration and visual bounds of an area on screen.
java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:com.myApp@82752ca
at android.app.ContextImpl.getSystemService(ContextImpl.java:1926)
at android.content.ContextWrapper.getSystemService(ContextWrapper.java:814)
at com.adjust.sdk.sig.NativeLibHelper.nSign(Native Method)
at com.adjust.sdk.sig.NativeLibHelper.sign(NativeLibHelper.java:15)
at com.adjust.sdk.sig.SignerInstance.sign(SignerInstance.java:112)
at com.adjust.sdk.sig.Signer.sign(Signer.java:74)
at java.lang.reflect.Method.invoke(Native Method)
at com.adjust.sdk.Reflection.invokeMethod(Unknown Source:8)
at com.adjust.sdk.Reflection.invokeInstanceMethod(Unknown Source:4)
at com.adjust.sdk.AdjustSigner.sign(Unknown Source:46)
at com.adjust.sdk.PackageBuilder.buildClickPackage(Unknown Source:69)
at com.adjust.sdk.PackageFactory.buildDeeplinkSdkClickPackage(Unknown Source:135)
Appcenter have the same bug in past, and this commit will help you https://github.com/facebook/facebook-android-sdk/commit/235a0a02692ac5a57d4c10b0bfb6477c9a003e99