Reputation: 712
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.
Upvotes: 9
Views: 41280
Reputation: 1
change the versipon of firse baseauth to some small cersion for example if ^5.0.0 then change to the some small for example ^4.5.2 then this solution can be resolve or any other pakge which is disturbing your execution
Upvotes: 0
Reputation: 7
this is my solution, add get properties from file local.properties with localProperties.getProperty.
sdk.dir=C:\\Users\\samor\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.versionCode=1
flutter.minSdkVersion=30
flutter.targetSdkVersion=33
flutter.compileSdkVersion=34
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.appname"
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
Upvotes: 0
Reputation: 712
It will work after changing the minSdkVersion to 21 at project_folder/android/app/build.gradle.
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Upvotes: 19
Reputation: 1
paste this code in the project's local.properties file
path: "android\local.properties"
sdk.dir=C:\\Users\\**"your pc's name"**\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\flutter
flutter.buildMode=debug
flutter.versionName=1.0.0
flutter.minSdkVersion=21
flutter.targetSdkVersion=31
flutter.compileSdkVersion=31
flutter.versionCode=1
replace the defaultConfig with this code in your build.gradle
path: "android\app\build.gradle"
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.rentatouille"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion localProperties.getProperty('flutter.minSdkVersion').toInteger()
targetSdkVersion localProperties.getProperty('flutter.targetSdkVersion').toInteger()
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Upvotes: 0
Reputation: 758
Try to add these lines to build.gradle file:
defaultConfig {
minSdkVersion 21
compileSdkVersion 33
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Upvotes: 0
Reputation: 56
This problem is happening because a package that you are using is not compatible with the new version of flutter
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
flutter clean
and flutter pub get
then run your applicationhope I could help.
Upvotes: 1
Reputation: 395
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]
Upvotes: 5
Reputation: 636
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'
}
app\build.gradle
defaultConfig {
applicationId "com.example.test"
minSdkVersion flutterMinSdkVersion.toInteger()
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
Upvotes: 4
Reputation: 11
android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
}
}
Result: Running with sound null safety 💪
Upvotes: 1
Reputation: 1067
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)
Upvotes: 0
Reputation: 837
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
}
}
Upvotes: -4