3

I tried adding the openweather api and when I try to sync the build.gradle file this error pops up

compileSdkVersion is not specified. Please add it to build.gradle

My File:

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'
}

I already have CompileSDK defined so idk why this still pops up.

Halil Ozel
  • 2,482
  • 3
  • 17
  • 32
FabianoPE
  • 31
  • 1
  • 2
  • Possibly relevant: https://stackoverflow.com/questions/67250362/what-is-difference-between-compilesdk-and-compilesdkversion-in-android-studio-gr – Joachim Sauer Jan 24 '23 at 11:38

1 Answers1

1

This error defines that you haven’t mentioned compileSdkVersion and not compileSdk. Although both means same but still if you are facing this issue mention compileSdkVersion in the build.gradle file.

This issue is relates with the new gradle changes in 7.0.0 so you can use compileSdkVersion with string and with int values like below.

android {
compileSdkVersion = "S"
//or with same number version
}
Khush Parmar
  • 316
  • 2
  • 9