Skip to content

Instantly share code, notes, and snippets.

@diewland
Last active April 27, 2022 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diewland/c0f2d2e71f1f9b8c756d33f267c277ae to your computer and use it in GitHub Desktop.
Save diewland/c0f2d2e71f1f9b8c756d33f267c277ae to your computer and use it in GitHub Desktop.
Run Kitkat app on Android 11

Run Kitkat app on Android 11

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.

java.lang.OutOfMemoryError

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"

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/commons/logging/LogFactory

implementation "commons-logging:commons-logging-api:1.1"

in build.gradle in app

INSTALL_FAILED_NO_MATCHING_ABIS

android {
    ...
    splits {
        abi {
            enable true
            reset()
            include 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'mips', 'mips64', 'arm64-v8a'
            universalApk false
        }
    }
}

in build.gradle in app

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