Issue
I'm quite stuck here despite having found a few quite similar Stack Overflow questions.
My specific case is trying to get an app to build on Android which I recently updated to Ionic 6 and most notably added Capacitor – while still using Cordova for a couple of plugins, but no longer for builds.
The work in progress is public on this branch.
The build error I get is:
Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 21 declared in library [:capacitor-app] /Users/noel/files/Dev/PasswordMaker/node_modules/@capacitor/app/android/build/intermediates/merged_manifest/release/AndroidManifest.xml as the library might be using APIs not available in 1
Suggestion: use a compatible library with a minSdk of at most 1,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.capacitorjs.plugins.app" to force usage (may lead to runtime failures)
As you can see, I've already:
- ensured
variables.gradlehas a sensibleminSdkVersionvalue – Capacitor 3 had already done this on setup I think - removed the top level SDK version manifest bits – I know this answer's about Cordova, but I don't seem to have a manifest at that path despite having some Cordova plugins still
- I temporarily tried this plugin version override option, but this still didn't build and I think would just get it to try and revert the plugin back to API v1 which is not what I want
I also tried some hail mary options like hard-coding a uses-sdk minimum version in the AndroidManifest.xml of every single module that shows up in Android Studio, but to no avail.
Any ideas would be much appreciated. Ideally I just want to build the project with minimum SDK 21, and target 30, without it falling over! The iOS build seems to be working fine and npx cap doctor reports no issues.
npx cap doctor
💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 3.3.3
@capacitor/core: 3.3.3
@capacitor/android: 3.3.3
@capacitor/ios: 3.3.3
Installed Dependencies:
@capacitor/android: 3.3.3
@capacitor/ios: 3.3.3
@capacitor/cli: 3.3.3
@capacitor/core: 3.3.3
[success] iOS looking great! 👌
[success] Android looking great! 👌
Solution
First Solition
In Android Studio, Select File > Project Structure.
In that window, on the left side, select the app module.
Once selected, click on the Flavors tab on the top of the window pane.
Set your minimum SDK version to 21.
Explanation: As Android updates to new versions, tools that developers use for Android change (& update or deprecate). Because of this, you cannot use new tools on an old version. Version 1 is the very first Android SDK (and we definitely don't want to be using that!). Capacitor requires the SDK be at least version 21.
Second Solution
If that doesn't work, we can always try rebuilding the android app all together. (Note: By doing this, you will lose any custom changes in the AndroidManifest.xml, a custom app icon, etc. If you haven't touched any of these things, then great!).
- Delete
androidfolder from the Ionic Project's root folder. - run command
ionic capacitor add android - run command
ionic capacitor build android - Build & run!
Answered By - Cooper Scott


0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.