Ionic 5 to change Android minSdkVersion from 21 to version 23

Issue

I’m trying out Ionic 5 App on android Emulator.

command: ionic capacitor run android -l --external

Error:

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 21 cannot be smaller than version 23 declared in library [androidx.security:security-crypto:1.0.0] 

Emulator:

Name: Pixel_2_API_27 CPU/ABI:
Google APIs Intel Atom (x86)
Target: google_apis [Google APIs] (API level 27) 
Skin: pixel_2 
SD Card: 100M

Package.json:

"@ionic/angular": "^5.5.2"
"@ionic-native/core": "^5.34.0",

Before on Ionic 4 we could change the config.xml

 <preference name"android-minSdkVersion" value"23" /> 

but in Ionic 5 I’m not sure how to change it.

Solution

On Capacitor you manage the minSdkVersion from gradle on:

yourProjectName\android\variables.gradle

I hope this be useful to you.

Answered By – Gabriel Sebastián López Illia

Leave a Comment