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

Fix Android strict mode warning #1623

Merged

Conversation

valeriopilo-tomtom
Copy link
Contributor

Android StrictMode helps Android developers identify application runtime issues.
StrictMode's detectUnbufferedIo() check specifically detects when any sort of un-buffered I/O is made.

This check is available in Android SDK 26+.

This fixes the following logcat warning + stacktrace:

StrictMode policy violation; ~duration=196 ms: android.os.strictmode.UnbufferedIoViolation
    at android.os.StrictMode$AndroidBlockGuardPolicy.onUnbufferedIO(StrictMode.java:1648)
    at libcore.io.IoTracker.trackIo(IoTracker.java:35)
    at java.io.FileOutputStream.write(FileOutputStream.java:398)
    at java.io.FileOutputStream.write(FileOutputStream.java:352)
    at java.util.zip.ZipOutputStream.writeInt(ZipOutputStream.java:722)
    at java.util.zip.ZipOutputStream.writeLOC(ZipOutputStream.java:398)
    at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:240)
    at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:109)
    at net.bytebuddy.android.AndroidClassLoadingStrategy.load(AndroidClassLoadingStrategy.java:142)
    at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101)
    at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6317)
    <..application code..>

In our instance, the application call was a simple ByteBuddy().subclass("class.name").make().load(classLoader, AndroidClassLoadingStrategy.Wrapping(File("name"))) on an app where StrictMode is enabled with most available checks enabled.

@raphw raphw merged commit 85baec7 into raphw:master Apr 22, 2024
@raphw raphw self-assigned this Apr 22, 2024
@raphw raphw added this to the 1.14.14 milestone Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants