ok, im sorry if this has been asked before, but.. i have literally been messing around with both android studio and visual studio code for days now, trying to figure this out, and haven’t been able to do it.
what i’ve been trying to do is make a flutter app, right (which im trying to integrate with firebase as well). im able to test it on microsoft edge fine, but… considering im aiming for a mobile app, i want to be able to test it using the emulator. but, no matter how many times i downloaded a new gradle version, or changed the java jdk i was using, changed the environmental variables regarding both jdk and gradle, reworded my code in my build.gradle/gradle-wrapper.properties/settings.gradle files, tried to rebuild/sync over and over using flutter clean/flutter pub get, etc etc etc… nothing’s worked. and ive tried looking up solutions on here already but. it seems like everything i try hasnt been working, so… im desperate at this point, honestly. i really need to figure this out like asap :/
whenever i try running my flutter app in the emulator, i get errors like this: "Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times."
however… i literally have updated my sdk tools in android studio countless times already. i even uninstalled and reinstalled both android studio and cmdline-tools multiple times, and have updated the code in my files to reflect those changes.
details i can give:
-
from running flutter doctor, Android SDK version is 34.0.0
-
java jdk is jdk-17 (since i heard android studio includes JDK 17 as its bundled Java version, figured this would work better for compatibility)
-
gradle for my system is 8.0.1
build.gradle (app):
plugins {
id "com.android.application"
id "kotlin-android"
id "com.google.gms.google-services" // Google services plugin
id "dev.flutter.flutter-gradle-plugin" // Flutter plugin
}
android {
namespace = "com.flutterapp.name"
compileSdk = 34
ndkVersion = "25.1.8937393"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
defaultConfig {
applicationId = "com.flutterapp.name"
minSdkVersion = 23
targetSdkVersion = 34
versionCode = 1
versionName = "1.0.0"
}
buildTypes {
release {
signingConfig = signingConfigs.debug
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:32.3.0')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-storage'
implementation 'com.google.android.gms:play-services-auth:20.4.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.core:core-ktx:1.12.0'
}
flutter {
source = "../.."
}
build.gradle (android):
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
(also, i have "distributionUrl=https://services.gradle.org/distributions/gradle-8.1-all.zip" in gradle-wrapper.properties, and flutter doctor doesn’t reveal any obvious errors either )
what am I doing wrong here? I dont understand what else I can do at this point… theres probably something Im missing but :(( im still kinda new to working with flutter, so.. please excuse me on that front, haha
2
Answers
I had a similar error just yesterday. I updated my Android Studio and then got the same build/gradle errors you are getting. The problem seems to relate to Flutter trying to use the built-in Android Studio JDK version (which, as of version Ladybug, seems to be beyond the compatibility of Flutter). You should run:
flutter doctor --verbose
to get the full Flutter doctor output. Then confirm what Java version Flutter is using. You can find this under the
If this is something other than 17 (as you described using), there is a discrepancy.
Now you just have to update the path Flutter uses for its JDK by running this command:
Also try cleaning your project using
flutter clean
and thenflutter pub get
.In my case, this solved the error. It took me way too long to figure out. Let me know if there are any more issues.
According to the
official documentation
, one of the most important things to consider when creating an emulator on Android Studio is:Please read the
create and manage virtual devices
documentation if there is something you need to check first,and I hope you set it up correctly
Now, on the issue of,
Have you tried this?
Go to Tools > SDK Manager > SDK Tools (Tab) > and update Android SDK Command-line Tools to latest.
Note that if any other SDK tools have a new version to update, update them too.
And to properly add
firebase
you have to only addfirebase_core
and then you consider not using the version of>= 3.7.0
because,Since your
Android SDK version is 34.0.0
So instead of manually adding the specific version of
firebase_core
plugin topubspec.yaml
, use the terminal to do so,flutter pub add firebase_core
Restart your Android Studio by manually closing and reopening it or if necesssary, perform
File > Invalidate Caches...
.Note: If the warning persists, you can ignore it for now without doing anything as long as your project runs as expected.
I hope it helps!