简体   繁体   中英

gradlew assembleRelease throwing compileSdkVersion is not specified error

I'm using gradle to build a react native app. I recently updated my Android SDK and now the following error is being thrown:

* What went wrong:
A problem occurred configuring project ':react-native-navigation'.
> compileSdkVersion is not specified.

This is my top level gradle.build:

buildscript {
ext {
    buildToolsVersion = "29.0.2"
    minSdkVersion = 16
    compileSdkVersion = 29
    targetSdkVersion = 29
}
repositories {
    google()
    jcenter()
}
dependencies {
    classpath("com.android.tools.build:gradle:3.5.3")
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

And this is my build script from inside the module:

android {
compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
    applicationId "com.myapp"
    minSdkVersion rootProject.ext.minSdkVersion
    targetSdkVersion rootProject.ext.targetSdkVersion
    versionCode 1
    versionName "1.0"
}

Anyone have any idea how I might fix it?

i solved the issue by adding ndk.dir in local.properties file.the local.properties file should look like this.

ndk.dir=/Users/[username]/Library/Android/sdk/ndk/your ndkversion ////23.1.7779620 sdk.dir=/Users/[username]/Library/Android/sdk

I stumbled upon the answer when I spotted another error. Something I installed must have required Kotlin, because the build started to complain that it wasn't there.

I added the following in my root build.gradle:

kotlinVersion = "1.3.72"
RNNKotlinVersion = "1.3.72"

And the following in my android/app build.gradle:

apply plugin: 'kotlin-android'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM