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

StrictMode policy violation on initialize #190

Open
jush opened this issue Feb 22, 2019 · 2 comments
Open

StrictMode policy violation on initialize #190

jush opened this issue Feb 22, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@jush
Copy link

jush commented Feb 22, 2019

We've StrictMode enabled in our app and we see the following policy violation:

StrictMode policy violation; ~duration=301 ms: android.os.strictmode.DiskReadViolation
        at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1504)
        at java.io.UnixFileSystem.checkAccess(UnixFileSystem.java:251)
        at java.io.File.exists(File.java:815)
        at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:605)
        at android.app.ContextImpl.ensurePrivateDirExists(ContextImpl.java:596)
        at android.app.ContextImpl.getDatabasesDir(ContextImpl.java:835)
        at android.app.ContextImpl.getDatabasePath(ContextImpl.java:814)
        at android.content.ContextWrapper.getDatabasePath(ContextWrapper.java:327)
        at com.amplitude.api.DatabaseHelper.<init>(DatabaseHelper.java:80)
        at com.amplitude.api.DatabaseHelper.getDatabaseHelper(DatabaseHelper.java:64)
        at com.amplitude.api.AmplitudeClient.initialize(AmplitudeClient.java:228)
        at com.amplitude.api.AmplitudeClient.initialize(AmplitudeClient.java:202)
        at <our_own_package>.<init>(AmplitudeClient.kt:22)

As seen in https://github.com/amplitude/Amplitude-Android/blob/master/src/com/amplitude/api/AmplitudeClient.java#L252 the database is opened in the thread calling the initialize.

Is there any chance that DB initialization could be moved inside the runOnLogThread to avoid accessing disk?

@haoliu-amp haoliu-amp added the bug Something isn't working label Feb 25, 2020
@prashanOS
Copy link

This seems to still be an issue in 2.36.1.

@haoliu-amp
Copy link
Contributor

Hello, all. We just released our new generation Android SDK. You can try to use this one instead. It doesn't have any 3rd party dependencies. @prashanOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants