小编Fab*_*oPE的帖子

未指定compileSdkVersion。请将其添加到 build.gradle:即使我在 build.gradle 文件中定义了它

我尝试添加 openweather api,当我尝试同步文件时,build.gradle会弹出此错误

未指定compileSdkVersion。请将其添加到build.gradle

我的文件:

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.example.myapplication'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.6.0'
    implementation 'com.google.android.material:material:1.7.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
Run Code Online (Sandbox Code Playgroud)

我已经定义了 CompileSDK,所以不知道为什么仍然会弹出这个问题。

java android gradle kotlin android-gradle-plugin

5
推荐指数
1
解决办法
9754
查看次数

标签 统计

android ×1

android-gradle-plugin ×1

gradle ×1

java ×1

kotlin ×1