'Could not find method compileSdk() for arguments [30] on extension 'android' of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension

I got the above error compileSdk() not found. While creating the app I have installed TargetSdk 31 and min SDK 19 But Apk does not install on Oreo Version so I have changed TargetSdk 31 to 31 and minSdk 19 to 16. I have uninstalled SDK 31 but it partially uninstalls. Please help me to solve this problem I am new to Android.



Solution 1:[1]

I have been strugling with this issue for hours until I looked at some older project. For some reason, newer versions of Android Studio mess up the directives from the Gradle file.

Just add "Version" after the name and it will work. So where you see "compileSdk" just rename it to "compileSdkVersion". You will probably also have to do that in "targetSdk" and so on.

Solution 2:[2]

in your <android_proj>/app/build.grandle instead of targetSdk 30 use:

android {
    ...
    defaultConfig {
        ...
        targetSdkVersion 30
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman
Solution 2 Adán Escobar