Android 16 / API 36 Adaptation Review

June 2, 2026 ยท View on GitHub

This review is scoped to this repository:

  • tools/ must keep collecting and interpreting memory data on Android 16 devices, including permission-denied fallbacks.
  • demo/memory-lab is a native-code demo APK. This document records the API 36 baseline; current master now targets API 37, so use android_17_adaptation_review.md for current SDK validation.
  • docs/ must explain which conclusions are supported by meminfo, smaps, showmap, hprof, dmabuf, and zram, and which are only hypotheses.

Current Status

AreaStatusEvidence
Android 16 SDKAPI 36 baseline retained; current demo SDK is superseded by Android 17 / API 37demo/memory-lab/app/build.gradle.kts, android_17_adaptation_review.md
AGP/GradleAGP 9.2.0, Gradle 9.4.1demo/memory-lab/build.gradle.kts, gradle-wrapper.properties
Edge-to-edgeExplicitly enabled with system bar and cutout insetsMainActivity.setupSystemBarInsets()
Predictive backNo custom back interception, no temporary opt-out requiredMainActivity
16 KB page sizeNon-legacy JNI packaging plus 16 KB ELF linker flagsapp/build.gradle.kts, CMakeLists.txt
Collection fallbackproc_meminfo, zram_swap, and dmabuf_debug are included; non-root capture continuestools/live_dumper.py, scripts/capture_memory_lab.sh

Device-side validation is still required on an Android 16 or 16 KB page-size environment.

Build Adaptation

Android 16 maps to API 36. This is the API 36 baseline; current master uses API 37. If validating an API 36 branch, compileSdk and targetSdk must be reviewed separately:

android {
    compileSdk = 36

    defaultConfig {
        targetSdk = 36
    }
}

compileSdk only allows access to API 36. targetSdk opts the app into Android 16 target-only behavior changes.

Before building, verify the local environment:

java -version
ls "$ANDROID_HOME/platforms/android-36"
ls "$ANDROID_HOME/build-tools/36.0.0"

16 KB Page Size

16 KB page size affects both installation/runtime compatibility and memory interpretation:

  • smaps still reports kB values; parsers must not assume 4 KB pages.
  • mmap, ashmem, DirectByteBuffer, and thread stack mappings can show larger page-rounding overhead.
  • Native .so files need 16 KB-compatible ZIP and ELF alignment.
  • Prebuilt SDK .so files must be checked as well.

The demo now uses non-legacy JNI packaging:

packaging {
    jniLibs {
        useLegacyPackaging = false
    }
}

The CMake target also has explicit 16 KB ELF alignment flags:

target_link_options(
        memorylab
        PRIVATE
        "-Wl,-z,max-page-size=16384"
        "-Wl,-z,common-page-size=16384")

Required validation:

cd demo/memory-lab
./gradlew :app:assembleDebug

APK=app/build/outputs/apk/debug/app-debug.apk
"$ANDROID_HOME/build-tools/36.0.0/zipalign" -c -P 16 -v 4 "$APK"

adb install -r "$APK"
adb shell getconf PAGE_SIZE

Pass criteria:

  • zipalign reports verification success.
  • 16 KB test environment returns 16384 from getconf PAGE_SIZE.
  • The native malloc/mmap scenario starts and clears without linker or mmap errors.

Runtime Behavior

For apps targeting API 36, Android 16 disables the edge-to-edge opt-out. The demo now explicitly enters edge-to-edge and applies systemBars | displayCutout insets to its content root.

Predictive back is enabled by default for target 36 apps on Android 16. The demo does not intercept back, so no manifest opt-out is needed. If custom exit/cancel behavior is added later, use supported AndroidX or platform back APIs rather than old key dispatch.

JobScheduler quota changes do not directly affect this Python+ADB collection flow. They can affect the app being analyzed, so Android 16 memory investigations should record foreground/background state, foreground-service state, and standby bucket when background work is part of the scenario.

Collection Matrix

SourceAndroid 16 riskCurrent strategy
dumpsys meminfo -dROM output sections can varyMain direction signal, cross-check with HPROF/smaps
gfxinfoGraphics fields vary by ROM/WebViewAuxiliary Graphics/GPU signal
smapsUser builds often deny accessDirect cat -> su -c -> su 0, then degrade
showmapMay be permission-limitedBest effort
/proc/meminfoUsually readableAlways collect system pressure context
zram/swapKernel fields varyCollect both new and old zRAM fields
dmabuf_debugdebugfs usually requires rootBest effort, do not treat missing data as zero
HPROFRequires debuggable/internal build or rootDemo debug build supports it

Review Checklist

  • API 36 branch or baseline has compileSdk = 36
  • API 36 branch or baseline has targetSdk = 36
  • AGP supports API 36 without suppressing warnings
  • JDK 17 and Build Tools 36 are available
  • APK passes zipalign -c -P 16
  • 16 KB environment reports PAGE_SIZE=16384
  • Edge-to-edge content does not overlap status/nav/cutout areas
  • No legacy back-key dependency
  • Capture includes build fingerprint, Android release/sdk, and page size
  • Non-root capture still produces a useful meminfo/gfxinfo/proc_meminfo/zram report

References