skip to Main Content

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:

  1. from running flutter doctor, Android SDK version is 34.0.0

  2. 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)

  3. 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


  1. 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.

    Login or Signup to reply.
  2. According 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.

    config

    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 consider not using 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....

    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!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search