Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An IllegalAccessException occurred while initialising CleverTap with applicationContext. #674

Open
boskicaruso opened this issue Oct 9, 2024 · 1 comment

Comments

@boskicaruso
Copy link

Describe the bug
An IllegalAccessException occurred while initialising CleverTap with applicationContext (following documentation)

To Reproduce

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        CleverTapAPI.getDefaultInstance(applicationContext)
    }

Screenshots/Logs
Tried to access visual service WindowManager from a non-visual Context:com.example.app.App@fbbaf9c WindowManager 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.example.app.App@fbbaf9c
at android.app.ContextImpl.getSystemService(ContextImpl.java:2235)
at android.content.ContextWrapper.getSystemService(ContextWrapper.java:936)
at com.clevertap.android.sdk.DeviceInfo$DeviceCachedInfo.getWidth(DeviceInfo.java:311)
at com.clevertap.android.sdk.DeviceInfo$DeviceCachedInfo.(DeviceInfo.java:110)
at com.clevertap.android.sdk.DeviceInfo.getDeviceCachedInfo(DeviceInfo.java:894)
at com.clevertap.android.sdk.DeviceInfo.getSdkVersion(DeviceInfo.java:633)
at com.clevertap.android.sdk.validation.ManifestValidator.checkSDKVersion(ManifestValidator.java:112)
at com.clevertap.android.sdk.validation.ManifestValidator.validate(ManifestValidator.java:33)
at com.clevertap.android.sdk.CleverTapAPI.lambda$manifestAsyncValidation$15$com-clevertap-android-sdk-CleverTapAPI(CleverTapAPI.java:2889)
at com.clevertap.android.sdk.CleverTapAPI$$ExternalSyntheticLambda5.call(D8$$SyntheticClass:0)
at com.clevertap.android.sdk.task.Task$1.run(Task.java:234)
at com.clevertap.android.sdk.task.PostAsyncSafelyExecutor.execute(PostAsyncSafelyExecutor.java:39)
at com.clevertap.android.sdk.task.Task.execute(Task.java:107)
at com.clevertap.android.sdk.CleverTapAPI.manifestAsyncValidation(CleverTapAPI.java:2887)
at com.clevertap.android.sdk.CleverTapAPI.lambda$new$9$com-clevertap-android-sdk-CleverTapAPI(CleverTapAPI.java:1171)
at com.clevertap.android.sdk.CleverTapAPI$$ExternalSyntheticLambda2.call(D8$$SyntheticClass:0)
at com.clevertap.android.sdk.task.Task$1.run(Task.java:234)
at com.clevertap.android.sdk.task.PostAsyncSafelyExecutor$1.run(PostAsyncSafelyExecutor.java:45)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)

Environment (please complete the following information):

  • Device: Pixel 7a
  • OS: Android 14
  • CleverTap SDK Version 7.0.1

Workaround
Use Activity Context instead

@Anush-Shand
Copy link
Contributor

Heyy @boskicaruso
Thanks for raising this. This seems to be a strict mode violation and was already detected in our internal audit.

As documented by android But don't feel compelled to fix everything that StrictMode finds here , this isn't extremely critical and hence we have added this to our roadmap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants