首页 > 解决方案 > gradlew assembleRelease 抛出 compileSdkVersion is not specified 错误

问题描述

我正在使用 gradle 构建一个反应原生应用程序。我最近更新了我的 Android SDK,现在抛出以下错误:

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

这是我的顶级 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
}

}

这是我在模块内部的构建脚本:

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

有人知道我该如何解决吗?

标签: androidreactjsreact-nativegradlereact-navigation

解决方案


我通过在 local.properties 文件中添加 ndk.dir 解决了这个问题。local.properties 文件应该是这样的。

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


推荐阅读