Android Studio ERROR: Manifest merger failed : uses-sdk:minSdkVersion - android

ERROR: Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.google.firebase:firebase-iid:19.0.0] C:\Users\User.gradle\caches\transforms-2\files-2.1\856a947c1a9c6ebc4d2fc0c2fb4dbece\firebase-iid-19.0.0\AndroidManifest.xml as the library might be using APIs not available in 15
Suggestion: use a compatible library with a minSdk of at most 15,
or increase this project's minSdk version to at least 16,
or use tools:overrideLibrary="com.google.firebase.iid" to force usage (may lead to runtime failures)
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.2.0' // Google Services plugin
}
dependencies {
// Add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.1.0'
}

minSdkVersion for firebase library is changed to API level 16 to align with the Google Play services distribution policy.
so you have to change your gradle file like
android {
...
defaultConfig {
minSdkVersion 16
..
}
}

Error says minSdkVersion 15 cannot be smaller than version 16
In that case:
Just change the minSdkVersion in gradle file to 16

The minimum SDK level required to use the most recently versions of Firebase libraries is 16. There is no workaround.
In your build.gradle file change the value with:
android {
...
defaultConfig {
minSdkVersion 16 //or higher
..
}
}

in your build.gradle file, please change the version higher than "minSdkVersion 15".

android {
compileSdkVersion 28
defaultConfig {
applicationId 'com.Demo'
minSdkVersion 21
targetSdkVersion 28
versionCode 10
versionName "1.6"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
and Add gradle :- implementation 'com.android.support:multidex:1.0.3'

Please go to build.gradle(Module.app) and update "minSdkVersion" to 16 or more as below:
defaultConfig {
.............
minSdkVersion 21
............
}
or upper then click on "Sync".

I encountered the same problem and the solution worked for me as follows:
You have to go to the build.gradle file .. app
and then to the defaultConfig{ . section
and replace this text
minSdkVersion flutter.targetSdkVersion
with this code
minSdkVersion 19
then click on "Sync".
Of course, this solution will work with those who work on Platform Flutter , Visual studio code

Related

My Flutter App is not running after adding cloud_firebase package

Recently I have added firebase to my flutter project. To use firebase database services I have added cloud_firebase package. But after adding this package my app is not running and giving me an exception:
BUILD FAILED in 31s
The plugin cloud_firestore requires a higher Android SDK version.
Fix this issue by adding the following to the file C:\Users\Jaguar\Desktop\AppDevelopment\acadmt\android\app\build.gradle:
android {
defaultConfig {
minSdkVersion 19
}
}
Note that your app won't be available to users running Android SDKs below 19.
Alternatively, try to find a version of this plugin that supports these lower versions of the Android SDK.
Exception: Gradle task assembleDebug failed with exit code 1
The exception message is also suggesting following suggestions:
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 19,
or use tools:overrideLibrary="io.flutter.plugins.firebase.firestore" to force usage (may lead to runtime failures)
I have tried the first two suggestions but still, the app is not working.
It will work after changing the minSdkVersion to 21.
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
For the Projects Created After Flutter 2.8 Update
Add this to project_folder/android/local.properties
flutter.minSdkVersion=21
Now update your project_folder/android/app/build.gradle
defaultConfig { minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger() }
Run flutter clean && flutter pub get
Rerun app
Reference: Change Android Minsdkversion in Flutter  –  2 Easy Ways [2022]
Previous Answers are also correct. I just used another approach.
First add flutter.compileSdkVersion=21 in local.properties file.
Then add this code in app\build.gradle
def flutterMinSdkVersion = localProperties.getProperty('flutter.minSdkVersion')
if (flutterMinSdkVersion == null) {
flutterMinSdkVersion = '21'
}
After this make sure minSdkVersion is added to defaultConfig inside app\build.gradle
defaultConfig {
applicationId "com.example.test"
minSdkVersion flutterMinSdkVersion.toInteger()
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
You may not apply changes after editing minSdkVersion
to solve this problem:
1-open build.gradle file and edit it:
android {
defaultConfig {
minSdkVersion 19
}
}
then on right side of android studio,make sure to select open for editing in android studio to apply changes and syncing gradle for new changes.
2-make a clean (File>invalidate Caches/Restart)
android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
}
}
Result: Running with sound null safety 💪
This problem is happening because a package that you are using is not compatible with the new version of flutter
Side note -> try not to upgrade flutter during working on an old project to avoid these problems
To solve it in flutter version 3.0.5 and after changing minSdkVersion and compileSdkVersion values place, you need to go to this path in your flutter sdk:
"your_flutter_sdk/packages/flutter_tools/gradle/flutter.gradle"
then update: minSdkVersion = 19 , compileSdkVersion = 31
static int compileSdkVersion = 31 //compile sdk new version
static int minSdkVersion= 19 //min sdk new version
static int targetSdkVersion = 31 //target sdk new version = compile sdk version
in terminal run flutter clean and flutter pub get then run your application
hope I could help.
Try to add these lines to build.gradle file:
defaultConfig {
minSdkVersion 21
compileSdkVersion 33
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Go to this path :
C:\Users\Jaguar\Desktop\AppDevelopment\acadmt\android\app\build.gradle
android {
defaultConfig {
minSdkVersion 19
}
}
change your minSdkVersion to 30
that is:
android {
defaultConfig {
minSdkVersion 30
}
}

Having error in android studio using kotlin

Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.google.firebase:firebase-auth:19.2.0] /home/shubham/.gradle/caches/transforms-2/files-2.1/782dd1b43e0016afc3d7d0a4252da9e3/firebase-auth-19.2.0/AndroidManifest.xml as the library might be using APIs not available in 15
Suggestion: use a compatible library with a minSdk of at most 15,
or increase this project's minSdk version to at least 16,
or use tools:overrideLibrary="com.google.firebase.auth" to force usage (may lead to runtime failures)
In your application modules' build.gradle; change minSdkVersion to at least 16.
Like so:
android {
defaultConfig {
applicationId "YOUR_APPLICATION_ID"
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0.0"
}
com.google.firebase.auth min 16 ,your project min is 15,you should change minSdkVersion to 16.the bad way to solve it is to your mainfest,it can be run but may be error when run

About Sdk and firebase

when i add these lines of firebase in andriod studio i got these errors
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.rashid"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
classpath 'com.google.gms:google-services:4.2.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
apply plugin: 'com.google.gms.google-services'
ERROR: Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [com.google.firebase:firebase-iid:19.0.0] C:\Users\hp.gradle\caches\transforms-2\files-2.1\db323219c95310ba498dc7530caba4e9\AndroidManifest.xml as the library might be using APIs not available in 15
Suggestion: use a compatible library with a minSdk of at most 15,
or increase this project's minSdk version to at least 16,
or use tools:overrideLibrary="com.google.firebase.iid" to force usage (may lead to runtime failures)
This is a small fix. In you build gradle (app), there should be a line of code that says:
minSDK 15
Change that 15 to a 16 or 17 and then it should work.

error: package android.support.multidex does not exist whem upgrading from minSdkVersion 16 to minSdkVersion 23

My app is not supporting Android 4.x and 5.x anymore, only Android 6.0 and higher. For that reason, in my app/build.gradle I changed minSdkVersion 16 to minSdkVersion 23. After doing that, I have started to get this error when I try to run the app:
error: package android.support.multidex does not exist
error: cannot find symbol variable MultiDex
In one of my .java files, I see the errors in the following lines:
import android.support.multidex.MultiDex;
MultiDex.install(this);
Should I simply not use MultiDex because Android 6.0 and higher do not need that anymore? This is considering that my app will not support Android 5.x and lower anymore. Thank you.
The solution to this problem is to add the following in Dependencies in build.gradle (:app):
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
...
}
https://developer.android.com/studio/build/multidex
I needed to change
import android.support.multidex.MultiDex
to
import androidx.multidex.MultiDex
to reference the "newer" MultiDex's location (version 1.0.3 in my case).
Try setting multiDexEnabled true in build.gradle(app)

Use of Configuration APKs while still targeting pre lollipop devices

When developing for Instant Apps the use of Configuration APKs (https://developer.android.com/topic/instant-apps/guides/config-splits.html) offers useful option for cutting down on APK size. However it looks like they are only supported when using mindSdk of 21 or later. For example, you get following error if you try to use this capability for lower sdk versions.
MinSdkVersion 17 is too low (<21) to support pure splits, reverting to full APKs
Is there way to have base module for example use pure split functionality while still having installed app target pre lollipop devices?
Since the minSdkVersion flag will toggle quite a few checks, this change is not done automatically for you.
I'd recommend introducing a product flavor for both the installed and instant module with different minSdkVersions, like this:
// :feature/base/build.gradle
flavorDimensions 'delivery'
productFlavors {
instant {
dimension 'delivery'
minSdkVersion rootProject.minSdkInstant
}
installed {
dimension 'delivery'
}
}
This will have to be done similarly in other modules that depend on the feature module with API level < 21.
Instant apps are only supported in API 21+ devices (link), older devices will only support full apk.
The better approach is to define different minSdk based on your module, like:
You can take a look at Google's analytics sample on GitHub
Project's gradle
ext {
buildTools = '26.0.2'
compileSdk = 26
minSdk = 15
minSdkInstant = 21
versionCode = 1
versionName = '1.0'
supportLib = '26.1.0'
firebaseVer = '10.2.4'
instantAppsVer = '1.0.0'
}
Base gradle
android {
compileSdkVersion rootProject.compileSdk
buildToolsVersion rootProject.buildTools
baseFeature true
defaultConfig {
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
versionCode rootProject.versionCode
versionName rootProject.versionName
}
buildTypes {
release {}
}
}
Installed gradle
defaultConfig {
applicationId "com.example.android.instant.analytics"
minSdkVersion rootProject.minSdk
targetSdkVersion rootProject.compileSdk
versionCode rootProject.versionCode
versionName rootProject.versionName
}
Instant gradle
android {
defaultConfig {
minSdkVersion rootProject.minSdkInstant
}
}
You can specify a different lower minSdkVersion for your application module if you use tools:overrideLibrary Please see How do I use tools:overrideLibrary in a build.gradle file?
This is how I did it:
app/build.gradle
android {
defaultConfig {
minSdkVersion 17
}
}
app’s manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package.app" xmlns:tools="http://schemas.android.com/tools" >
<uses-sdk tools:overrideLibrary="com.package,com.package.feature"/>
</manifest>
You will need to add all the package names where you wish to override their minSdkVersion. You will know which ones to add by looking at the error:
Manifest merger failed ...
AndroidManifest.xml as the library might be using APIs not available
in 17 Suggestion: use a compatible library with a minSdk of at most
17,
or increase this project's minSdk version to at least 21,
or use tools:overrideLibrary="com.package.feature" to force usage (may lead to runtime failures)
base and feature/build.gradle
android {
defaultConfig {
minSdkVersion 21
}
}
Test it by building the installed/instant APKs, then analyzing then for the minSdkVersion value. The installed should be at 17, and your base/feature APKs will still be on 21.

Categories

Resources