Reputation: 3526
I have an Android (Java) source code, in which I have integrated the Flutter module. When I run my Android application in Android Studio I get the following error. I know the solution is very straightforward. Perhaps the error itself suggests the solutions. However, I can't implement those solutions as I get the following error for multiple flutter packages I am using, in my Flutter source code. How do I resolve this without changing minSdkVersion in the Android app?
Let me explain the structure of the source code I have.
--Android_A --- It has all the Android source code
--Flutter_B --- It has flutter code
--Flutter_C --- It is a git submodule with flutter source code again.
The pubspec.yaml
inside each flutter module above has a line indicating the dependencies. E.g
Flutter_C/pubspec.yaml
has the following line
Flutter_B:
path: ../../Flutter_B
Similarly Flutter_B/pubspec.yaml
has the following line
Flutter_C:
path: Flutter_C
Finally, Android_A/settings.gradle has the following lines.
include ':app'
setBinding(new Binding([gradle: this]))
evaluate(new File(
settingsDir.parentFile,
'Flutter_B/.android/include_flutter.groovy'
))
Manifest merger failed : uses-sdk:minSdkVersion 19 cannot be smaller than version 21 declared in library [:payu_checkoutpro_flutter]
~/pm_module/.android/plugins_build_output/payu_checkoutpro_flutter/intermediates/merged_manifest/debug/AndroidManifest.xml as the library might be using APIs not available in 19
Suggestion: use a compatible library with a minSdk of at most 19,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.payubiz.payu_checkoutpro_flutter" to force usage (may lead to runtime failures)
I tried changing minSdkVersion as the error suggests, but unfortunately, I receive this error for so many packages.
There are other SO posts similar to this problem, but they are also talking about a single package.
It was working well in the current setup, it suddenly started throwing this issue.
I even ran the git reset
and flutter clean
, flutter pub get
and similar commands.
Upvotes: 1
Views: 380
Reputation: 35
If you haven't already, you can enable multidex support in your Android project. Multidex support allows your app to build and run on older Android versions that have a limitation on the number of methods in a single dex file. To enable multidex, follow these steps :
In your build.gradle
file (typically located in the android/app
directory), add the following lines inside the android
block:
android {
defaultConfig {
...
multiDexEnabled true
}
}
Also, make sure to include the multidex dependency in your dependencies
block:
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
Finally, update your AndroidManifest.xml
to include the multidex application class :
<application
android:name="androidx.multidex.MultiDexApplication">
...
</application>
Upvotes: 0