admin管理员组文章数量:1332896
I've been trying to make a Flutter app. I'm trying to integrate it with Firebase as well.
I was able to test it on Microsoft Edge fine, but... considering that I'm 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,
I've changed the environment variables regarding both JDK and Gradle, and reworded my code in my build.gradle
, gradle-wrapper.properties
, settings.gradle
files, and tried to rebuild/sync
over and over using flutter clean
and flutter pub get
, and so on. but then nothing's worked.
I've already tried looking up solutions on here, but it seems like everything I tried hasn't been working.
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 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.
The 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, I 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 ".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=.1-all.zip
in gradle-wrapper.properties
, and flutter doctor
doesn't reveal any obvious errors either
What am I doing wrong here?
I've been trying to make a Flutter app. I'm trying to integrate it with Firebase as well.
I was able to test it on Microsoft Edge fine, but... considering that I'm 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,
I've changed the environment variables regarding both JDK and Gradle, and reworded my code in my build.gradle
, gradle-wrapper.properties
, settings.gradle
files, and tried to rebuild/sync
over and over using flutter clean
and flutter pub get
, and so on. but then nothing's worked.
I've already tried looking up solutions on here, but it seems like everything I tried hasn't been working.
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 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.
The 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, I 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 ".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./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?
Share Improve this question edited Nov 23, 2024 at 16:45 halfer 20.3k19 gold badges109 silver badges202 bronze badges asked Nov 21, 2024 at 4:10 kmccckmccc 211 bronze badge 13 | Show 8 more comments2 Answers
Reset to default 1According to the official documentation
, one of the most important things to consider when creating an emulator on Android Studio is:
The API level of the target device is important, because your app doesn't run on a system image with an API level that's lower than the one required by your app, as specified in the minSdk attribute in the app manifest file. For more information about the relationship between system API level and minSdk, see
Version your app
.
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,
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.
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 add firebase_core
and then you need to consider to not use the version of >= 3.7.0
because,
update Android SDK to version 33.5.1
Since your Android SDK version is 34.0.0
So instead of manually adding the specific version of firebase_core
plugin to pubspec.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...
.
If you still want to resolve the warning, just maintain the latest Android Command-line Tools
and Android Studio
versions.
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!
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
Android Toolchain section: Java version Java(TM) SE ... (build ?).
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:
flutter config --jdk-dir=<PATH_TO_JDK_17_DIR>
Also try cleaning your project using flutter clean
and then flutter 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.
本文标签:
版权声明:本文标题:Cannot run Flutter app on Android emulator, no matter how hard I try, and keep getting more and more errors - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742314850a2451609.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
flutter doctor -v
command for more detailed output. – DevQt Commented Nov 21, 2024 at 9:55