Repository navigation
fix: verify native and plugin APKs with aapt2 - #6670
Conversation
aapt rejects a binary manifest attribute whose value type does not match, such as the string android:required that a Godot default-renderer export writes. aapt2 reads the same APK and prints the package and native-code lines identically. Closes #6668
|
Fresh review of 2b19bcd: no actionable findings. Real tools. I ran I also built APKs with No fallback. Other readers. Compatibility. Tests.
The fixtures are still real APKs signed by Description. It follows the template, matches the diff and links the issue. Pre-existing, not from this change. The ABI check reads only the Not verified. Windows and Linux build-tools, and build-tools older than 30.0.3. None are installed here. |
Description
Stim checks every native Android artifact and every APK a project plugin builds with
inspectApk, which readsdump badgingfor the package name, thesplit=refusal and thenative-codeABIs. It ran the legacyaapt, andplugin-android.tsrefused a plugin build when the SDK had noaapt.aaptis strict about attribute value types in a binary manifest. Godot's Android exporter patches the manifest of its prebuilt template and writesandroid:requiredandandroid:versionof the Vulkanuses-featureentries as strings, soaaptfails on every Godot export that uses the default renderer:aapt2reads the same APK, and the device installs it.Solution
inspectApkand the plugin build's tool check useaapt2instead ofaapt, with the samedump badging <apk>arguments. The refusal texts nameaapt2.No
aaptfallback.aapt2has shipped in every build-tools release since 26.0.0. Stim has no build-tools floor of its own, and it signs withapksigner, which the check already requires. The build-tools that haveapksignerbut noaapt2are 24.0.3 to 25.0.3, from 2016 and 2017, and no Android Gradle Plugin that current React Native, Expo or Godot use accepts them. A fallback would need a version-first search, becausefindBuildToolwalks versions newest first and stops at the first match. With['aapt2', 'aapt'], a newer directory holding onlyaaptwould win and the Godot failure would come back. It would also be a branch that no build-tools on a test machine can exercise.findBuildTool(['aapt2'])still falls back to an older build-tools directory when the newest has noaapt2, for example a partial36.0.0-rc5install.The two tools print the lines Stim parses identically (see the test plan). An existing cache receipt holds the same package and ABIs either way, so cached APKs stay valid.
aapt2printswarn:lines for the Godot APK on stderr. They do not start withpackage:ornative-code:, and the dump exits 0.scripts/build-compat.jsongets a new digest and noSTIM_BUILD_COMPATbump: a worker with either version builds the same artifact, and the change only makes a failing build succeed.Test plan
Real tools, build-tools 37.0.0 on macOS. The lines
inspectApkparses, from each tool'sdump badging:aaptaapt2package: name='nitrofetch.example' versionCode='1' versionName='1.0' platformBuildVersionName='17' ...,native-code: 'arm64-v8a'native-code: 'arm64-v8a' 'armeabi-v7a' 'x86' 'x86_64'aapt2 linkfrom a manifest withsplit="config.x86_64"package: name='dev.stim.split.probe' versionCode='1' versionName='1' split='config.x86_64' ...aapt packagepackage: name='dev.stim.cache.compat' ...android:requirederror abovepackage: name='dev.stim.godotcheck' versionCode='1' versionName='1.0.0' ...,native-code: 'arm64-v8a'The
aapt2of build-tools 30.0.3 and 34.0.0 print the samepackage:andnative-code:lines for the four-ABI APK and the split APK.End to end, with this branch's build in a scratch Stim home and the Godot project plugin:
stim androidin a Godot 4.7.2 project with the default renderer exported the APK, passed the check (build ok), installed it on an owned emulator and launched it. The first launch on the freshly booted emulator exited, because a system overlay update recreated the activity before Godot had started. A secondstim androidon the settled emulator passed the launch check (OK: dev.stim.godotcheck launched). The process stayed alive, runningVulkan 1.2.293 - Forward Mobile.Tests:
native-android-cache.compat.test.tsnow builds its fixture APKs withaapt2 link, so the probe needsaapt2,apksignerandkeytool. It also checks that a real signed split APK is refused, which no test covered before. Removing thesplit=check makes this probe fail.pnpm run test:compat packages/stim-cli/src/__tests__/native-android-cache.compat.test.tspasses (2 cases).native-android-cache.test.ts(32 passed),plugin-android.test.ts(9 passed) andtest/e2e/native-source-worker.e2e.jsare renamed fromaapttoaapt2. With the old code, these fakes leave noaaptin the SDK.docs/testing.mdnamesaapt2for the probe.pnpm run format:check,pnpm run lint,pnpm run build,pnpm run typecheckandpnpm run knippass.Fixes #6668