gradlew assembleRelease 抛出 compileSdkVersion 未指定错误

时间:2020-12-22 21:40:49

标签: android reactjs react-native gradle react-navigation

我正在使用 gradle 构建一个 React Native 应用程序。我最近更新了我的 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"
}

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

1 个答案:

答案 0 :(得分:0)

当我发现另一个错误时,我偶然发现了答案。我安装的东西一定需要 Kotlin,因为构建开始抱怨它不存在。

我在我的根 build.gradle 中添加了以下内容:

kotlinVersion = "1.3.72"
RNNKotlinVersion = "1.3.72"

以及我的 android/app build.gradle 中的以下内容:

apply plugin: 'kotlin-android'