Reputation: 361
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:
variables.gradle
has a sensible minSdkVersion
value ā Capacitor 3 had already done this on setup I thinkI 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! š
Upvotes: 1
Views: 1667
Reputation: 706
First Solution
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!).
android
folder from the Ionic Project's root folder.ionic capacitor add android
ionic capacitor build android
Upvotes: 1