【问题标题】:gradlew assembleRelease throwing compileSdkVersion is not specified errorgradlew assembleRelease 抛出 compileSdkVersion is not specified 错误
【发布时间】:2020-12-22 21:40:49
【问题描述】:

我正在使用 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"
}

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

【问题讨论】:

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


    【解决方案1】:

    我通过在 local.properties 文件中添加 ndk.dir 解决了这个问题。local.properties 文件应该如下所示。

    ndk.dir=/Users/[用户名]/Library/Android/sdk/ndk/你的ndkversion ////23.1.7779620 sdk.dir=/Users/[用户名]/Library/Android/sdk

    【讨论】:

      【解决方案2】:

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

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

      kotlinVersion = "1.3.72"
      RNNKotlinVersion = "1.3.72"
      

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

      apply plugin: 'kotlin-android'
      

      【讨论】:

        猜你喜欢
        • 2012-09-15
        • 1970-01-01
        • 2022-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多