ReviewOS

craft-native/craft

android: enforce the runtime minimum SDK contract

#273
Closed glennmichael123 opened this 10 days ago ·
10 days ago

Problem

The Android generator documents and defaults to minSdk: 26, and generated runtime code assumes that floor, but validateAndroidConfig accepts any positive integer. A caller can therefore generate an APK declaring an API level below the runtime contract.

The gap is now especially concrete in the #254 recovery path: MainActivity.kt.template calls ConnectivityManager.registerDefaultNetworkCallback, introduced in API 24, whenever a remote app has a bundled fallback. A custom minSdk below 24 remains accepted and can fail only at runtime. Other generated APIs should be audited against the intended floor as well.

This was found while auditing #254 after merge; it is outside that issue’s exact fallback behavior.

Suggested acceptance criteria

  • Define one canonical supported Android API floor (currently documented/defaulted as 26).
  • Reject lower configured minSdk values with a diagnostic that names the required floor, or deliberately guard every newer runtime call if lower APIs are intended to remain supported.
  • Keep the generator default, README, and generated Gradle fallback value in sync.
  • Add a generator test for one value below the floor and the floor itself.
  • Audit unconditional generated Kotlin dependencies/calls against the selected floor.

Sign in to comment on this issue.