How can I resolve the Gradle Sync problem?
I installed the missing SDK versions but the error shown again.
Take a look to the screenshots please...
Screenshot 1
Screenshot 2
Thank you in advance.
Your compileSdkVersion must be a number, not a String
Example:
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.yourpackage.yourapp"
minSdkVersion 11
targetSdkVersion 24
versionCode 4
versionName "1.3"
}
...
}
You also need to open up "build.gradle" script and change the classpath to latest gradle repository.... mine is 'com.android.tools.build:gradle:3.0.0-alpha3'
Hope this helps everyone
Related
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
}
}
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
Recently I've been getting this problem.
As far as I know, there is no 26.X.X versions of these support libraries, what does Gradle wants from me?
After reviewing a previous question, you may want to be sure that your compileSdkVersion matches across the board, if you want to build in 25 but you are in 23.
This support library should not use a different version Error in build.gradle
You can confirm versions by >> Create new project in Android studio >> Press Ctrl+Shift+Alt+S >> Proceed to 'Project' section >> You can see actual gradle version and android pluging version. Copy that to your project.
The problem lies in your Compile version in build.gradle file.
It seems, your compile version is 26.
Please change your compile version to 25 and sync gradle.
compileSdkVersion 25
buildToolsVersion "25.0.3"
Please set your Compile Version to 25
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.user.xxxxx"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
I get this error when trying to build my app:
Could not find com.android.support.constraint:constraint-layout:1.0.0-alpha1
Required by:
MyApp:app:unspecified
Gradle version:
classpath 'com.android.tools.build:gradle:2.3.0-alpha2'
Android studio version;
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "MyApp"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
I tried going to SDK TOOLS and enabling the constraint solver, but I did not help. This happened just today, and have not have had this issue earlier. Any ideas?
Check if you have installed ConstraintLayout. Open SDK Manager and than in SDK Tools tab you can check what version of ConstarintLayout is installed.
Masters,
Recently I am trying to build android project with gradle, and since there one API(#JavascriptInterface annotation) I need to use is only up to api level 17, so I changed my targetAPILevel to 19 in project properties. And it works well when I build the project from Eclipse(Right click on project and Run Android Application).
But when I tried to build the project by gradlew in terminal, it seems it never use target level 19 to build the project. Here is part of the build.gradle file as follow:
android {
// target = 'android-19'
compileSdkVersion 19
buildToolsVersion '19.0.1'
}
Can anyone help me what I did wrong in here, please? Thank you very much.
TargetSdkVersion and compileSdkVersion are different parameters.
In eclipse, you set the target in your Manifest, and set the api used to compile with right click -> properties -> Android Manu.
In your build.gradle you should use something like this:
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
}