android_sdk icon indicating copy to clipboard operation
android_sdk copied to clipboard

IncorrectContextUseViolation

Open eloev opened this issue 2 years ago • 0 comments

When adjust trying to send event, I catch this

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)

I re-read all documentations, but I don't find solution to fix this. I tried passing visual context via createWindowContext, or activity context, but it's too not helped me. I can't fork this method since it's native to find out exactly what the problem is. But I found commit in appcenter, with similar trouble, may be it's helped Your team to solve this.

And, when I tried to handle deeplink in adjust sdk, I catched the same problem

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)

If I'm right, you need to change the WindowManager'a method to DisplayManager to fix this. And thank's for reply, guys)

eloev avatar Jun 07 '22 11:06 eloev