【问题标题】:Github Actions Flutter CI Error: No version of NDK matchedGithub Actions Flutter CI 错误:没有匹配的 NDK 版本
【发布时间】:2020-07-23 13:17:53
【问题描述】:

Project Repository

我一直在推commit

但是,我得到了error

* What went wrong:
Execution failed for task ':app:stripReleaseDebugSymbols'.


> No version of NDK matched the requested version 20.0.5594570. Versions available locally: 21.0.6113669

以下是 CI 代码(Flutter CI - Customer):

name: Flutter CI - Customer

on:
  push:
    branches:
      - master
    paths:
      - holinoti_customer/**
      - .github/workflows/flutter-customer.yml

  pull_request:
    branches:
      - master
    paths:
      - holinoti_customer/**

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2.0.0
    - name: Set up JDK 11
      uses: actions/setup-java@v1
      with:
        java-version: 11.0.2
    - name: Android NDK toolchain Setup
      uses: ravinderjangra/android-ndk-toolchain-setup@0.1
      with: 
        api: '21'
        arch: 'arm'
        install-location: 'toolchains'
    - uses: subosito/flutter-action@v1.1.1
      with:
        flutter-version: '1.12.x' # you can use 1.12
    - name: Install dependencies
      run: flutter pub get
      working-directory: holinoti_customer
    - name: Test Build
      run: flutter build apk
      working-directory: holinoti_customer

在我的本地项目中,我在android studio的项目结构中设置了ndk路径

但是,此解决方案无法应用于 Github Action

所以,我尝试使用Android NDK toolchain Setup,但仍然失败

【问题讨论】:

    标签: flutter github android-ndk continuous-integration github-actions


    【解决方案1】:

    不要使用 local.properties 文件,而是在 build.gradle 中设置 ndkVersion 以匹配 CI 服务器上可用的那个。即

    android {
        ndkVersion "21.1.6352462"
    }
    

    (我假设您的 CI 已更新以使 r21b 从那时起可用,否则使用错误消息中的 21.0.blah 版本。)

    这样您的 CI 和本地构建都使用相同的版本。

    这就是这个改变的动机,顺便说一句:保持构建的可重复性。以前你的 CI 和你的本地构建使用不同版本的 NDK,这可能是一个令人惊讶和恼人的错误来源:)

    【讨论】:

    • 在 Github Actions 代理上安装另一个 NDK 版本怎么样?无论如何从命令行安装NDK? NDK 文件应该在 Github Actions 代理上的什么位置?
    • 在 build.gradle 中设置该属性会在需要时下载 NDK。对于 AGP 4.1+,即使没有上述设置,也会在需要时下载。
    • 非常有帮助!几天来一直坚持这个类似的错误,我把我带到了这里。还要感谢 OP 发布这个问题。为什么还需要这个?
    【解决方案2】:

    检查 SDK 工具的更新会更新 NDK 和 CMake 工具。

    【讨论】:

    • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
    猜你喜欢
    • 2022-09-23
    • 2020-06-09
    • 2021-12-09
    • 2020-09-06
    • 2020-06-09
    • 2020-01-08
    • 2022-10-19
    • 2020-07-01
    • 2020-02-03
    相关资源
    最近更新 更多