add 2 properties to in Manifest file
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
build.gradle (app) set targetSdkVersion to 29
android {
compileSdkVersion 29
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.diewland.writefiledemo"
minSdkVersion 17
targetSdkVersion 29 <--
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
https://developer.android.com/about/versions/11/privacy/storage#scoped-storage
Apps that run on Android 11 but target Android 10 (API level 29) can still request the requestLegacyExternalStorage attribute. This flag allows apps to temporarily opt out of the changes associated with scoped storage, such as granting access to different directories and different types of media files. After you update your app to target Android 11, the system ignores the requestLegacyExternalStorage flag.
sample
2022-04-27 15:35:47.256 2468-2477/? E/System: java.lang.OutOfMemoryError: Failed to allocate a 24 byte allocation with 736 free bytes and 736B until OOM
at com.android.internal.os.BinderInternal$GcWatcher.finalize(BinderInternal.java:53)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:222)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:209)
at java.lang.Thread.run(Thread.java:761)
add 1 property to in Manifest file
android:largeHeap="true"
implementation "commons-logging:commons-logging-api:1.1"
in build.gradle
in app
android {
...
splits {
abi {
enable true
reset()
include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a'
universalApk false
}
}
}
in build.gradle
in app