'Specifying the element uses-sdk in AndroidManifest makes the manifest unparsable at runtime, when AAPT is used
I observe a real weird problem: I build .apk package using base tools as aapt, d8 and so on. The manifest file has the following line:
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="32"/>
If I try to deploy the .apk , then the following problem reported by the packageinstaller:
2022-05-07 11:45:07.491 5998-5998/com.google.android.packageinstaller W/PackageInstaller: Parse error when parsing manifest. Discontinuing installation
And a user see the following message:

But if I remove the element "uses-sdk" from the manifest, then the app gets installed without a problem and works. But it looks like it considers a very low target number. What did I do wrong?
Note: the build procedure doesn't use Gradle, it uses 7Bee. I can provide github link to the app, if you are interested in.
Solution 1:[1]
When I looked in an addressing the issue, I found the following:
- AAPT is discontinued
- AAPT2 has to be used now
- AAPT2 a gets version information as parameters of a run
- AAPT2 produced result has to be signed using the apksigner SDK tool
- APK has to be prepared by the ApkBuilderMain SDK tool
- The ApkBuilderMain needs to be patched because not allows META-INF directory in APK content
After addressing all these items, APK got normally packaged and works.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user2305886 |
