gradle 错误:调用需要API级别24(当前最小值为23),而在GitHub上构建操作

hmtdttj4  于 2023-08-06  发布在  Git
关注(0)|答案(1)|浏览(135)

使用GitHub Actions编译我的Android应用程序时,我收到以下错误:

Call requires API level 24 (current min is 23): java.lang.Iterable#forEach [NewApi]
        entryValues.forEach { entryValue ->

字符串


的数据

这是我的build action yml文件

name: Android CI
on:
  push:
    branches: [ "dev" ]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Fetch Sources
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Setup JDK
        uses: actions/setup-java@v3
        with:
          distribution: zulu
          java-version: '11'

      - name: Setup Android SDK
        uses: android-actions/setup-android@v2

      - name: Setup Gradle
        uses: gradle/gradle-build-action@v2
        with:
          gradle-version: 7.4

      - name: Setup Gradle Cache
        uses: actions/cache@v2
        with:
          path: |
            ~/.gradle/caches
            ~/.gradle/wrapper
          key: >-
            ${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{
            hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{
            hashFiles('**/buildSrc/**/*.kt') }}

      - name: Execute Gradle build
        run: ./gradlew build

这是我的应用级gradle配置

compileSdk 33

minSdk 23

targetSdk 33

compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
        jvmTarget = '1.8'    
}

这是我的项目级Gradle配置

plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
}

设置分级

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        flatDir {
            dirs 'app/libs'
        }
    }
}
rootProject.name = "Project"
include ':app'

上述Gradle配置运行正常,构建在我的PC上成功运行。

以上Gradle配置工作正常,构建在我的PC上成功运行。

gojuced7

gojuced71#

尝试改变

minSdk 23

字符串

minSdk 24

相关问题