admin管理员组

文章数量:1277316

I am trying with help of chatGPT to compile my flutter/android build in Visual Studio Code. It worked before and now it does not.

This is my app/build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "com.google.gms.google-services"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

dependencies {
    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:33.9.0')

    // Add required Firebase dependencies here
    implementation 'com.google.firebase:firebase-messaging'
}

android {
    compileSdk 35 //rootProject.extpileSdkVersion
    namespace = "com.example.kommunappen"
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17
    }

    defaultConfig {
        applicationId "com.example.kommunappen"
        minSdk 28//rootProject.ext.minSdkVersion
        targetSdk 35 //rootProject.ext.targetSdkVersion
        versionCode flutter.versionCode
        versionName flutter.versionName
    }

    println("compileSdkVersion: " + androidpileSdkVersion)

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}

This is my android/build.gradle

plugins {
    id 'com.android.application' 
    id "kotlin-android"
    id 'com.google.gms.google-services' version '4.4.2' apply true
}

ext {
    kotlin_version = '1.8.20'
    compileSdkVersion = 35
    targetSdk = 35
    minSdk = 28
    appCompatVersion = "1.6.1"
    playServicesLocationVersion = "21.3.0"
    hmsLocationVersion = "6.12.0.300"
    removeBackgroundGeolocationDebugSoundsInRelease = false
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url "${project(':flutter_background_geolocation').projectDir}/libs" }
        maven { url '/' }
        maven { url "${project(':background_fetch').projectDir}/libs" }
        jcenter()
    }
}

println("DEBUG: compileSdkVersion from ext is: " + extpileSdkVersion)

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(":app")
}

My println gives DEBUG: compileSdkVersion from ext is: 35 compileSdkVersion: android-35

Still I get the error: A problem occurred configuring root project 'android'.

com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

I tried to build my Android project and expected it to work. Instead it throws this error and I cannot figure out what is wrong.

I am trying with help of chatGPT to compile my flutter/android build in Visual Studio Code. It worked before and now it does not.

This is my app/build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "com.google.gms.google-services"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
}

dependencies {
    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:33.9.0')

    // Add required Firebase dependencies here
    implementation 'com.google.firebase:firebase-messaging'
}

android {
    compileSdk 35 //rootProject.extpileSdkVersion
    namespace = "com.example.kommunappen"
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17
    }

    defaultConfig {
        applicationId "com.example.kommunappen"
        minSdk 28//rootProject.ext.minSdkVersion
        targetSdk 35 //rootProject.ext.targetSdkVersion
        versionCode flutter.versionCode
        versionName flutter.versionName
    }

    println("compileSdkVersion: " + androidpileSdkVersion)

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}

This is my android/build.gradle

plugins {
    id 'com.android.application' 
    id "kotlin-android"
    id 'com.google.gms.google-services' version '4.4.2' apply true
}

ext {
    kotlin_version = '1.8.20'
    compileSdkVersion = 35
    targetSdk = 35
    minSdk = 28
    appCompatVersion = "1.6.1"
    playServicesLocationVersion = "21.3.0"
    hmsLocationVersion = "6.12.0.300"
    removeBackgroundGeolocationDebugSoundsInRelease = false
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url "${project(':flutter_background_geolocation').projectDir}/libs" }
        maven { url 'https://developer.huawei/repo/' }
        maven { url "${project(':background_fetch').projectDir}/libs" }
        jcenter()
    }
}

println("DEBUG: compileSdkVersion from ext is: " + extpileSdkVersion)

rootProject.buildDir = "../build"
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(":app")
}

My println gives DEBUG: compileSdkVersion from ext is: 35 compileSdkVersion: android-35

Still I get the error: A problem occurred configuring root project 'android'.

com.android.builder.errors.EvalIssueException: compileSdkVersion is not specified. Please add it to build.gradle

I tried to build my Android project and expected it to work. Instead it throws this error and I cannot figure out what is wrong.

Share Improve this question asked Feb 25 at 10:58 Martin HolménMartin Holmén 92 bronze badges 4
  • May I know why you commented //rootProject.extpileSdkVersion and directly added 35? – Vijay Commented Feb 26 at 2:23
  • As part of trying to find the error. Both give the same result though. – Martin Holmén Commented Feb 26 at 14:10
  • Add an = between the compileSdk and 35 – Nnamani Daniel Commented Feb 28 at 11:54
  • Same error with the added = – Martin Holmén Commented Feb 28 at 12:48
Add a comment  | 

2 Answers 2

Reset to default 0

Your compileSdkVersion = 35 means nothing and is not what it is asking for. You need to replace compileSdk in your apps build.gradle with compileSdkVersion

In the Android/build.gradle, remove everything before allprojects{

本文标签: