'No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi github actions

Today when I build the flutter(2.8.0) android app in github actions, show error like this:

Calling mockable JAR artifact transform to create file: /Users/runner/.gradle/caches/transforms-2/files-2.1/fd7563296d8e036c5444c9195bb0e093/android.jar with input /Users/runner/Library/Android/sdk/platforms/android-31/android.jar
Removed unused resources: Binary resource data reduced from 59KB to 51KB: Removed 12%

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:stripProdReleaseDebugSymbols'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5m 2s
Running Gradle task 'assembleProdRelease'...                      304.9s
Gradle task assembleProdRelease failed with exit code 1
Error: Process completed with exit code 1.

In my local machine in android emulator, the app compile and runs success. what should I do to fix this compile problem in github actions? this is the github actions build.yaml:

name: Cruise-Android

on:
  push:
    branches: [ main, android ]

jobs:
  build:
    #
    # more macOS version:
    # https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md
    #
    runs-on: macos-10.15
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v1
        with:
          java-version: '12.x'
      - uses: subosito/flutter-action@v1
        with:
          flutter-version: '2.8.0'
      - name: Install tools
        run: |
          flutter precache
          flutter pub get
      #- run: flutter pub get
      #- run: flutter build apk
      - run: flutter build apk --release --flavor prod -t lib/main_pro.dart --no-sound-null-safety
      - name: Setup SSH Keys and known_hosts for fastlane match
        run: |
          SSH_PATH="$HOME/.ssh"
          mkdir -p "$SSH_PATH"
          touch "$SSH_PATH/known_hosts"
          echo "$PRIVATE_KEY" > "$SSH_PATH/id_rsa"
          chmod 700 "$SSH_PATH"
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          chmod 600 "$SSH_PATH/known_hosts"
          chmod 600 "$SSH_PATH/id_rsa"
          eval $(ssh-agent)
          ssh-add "$SSH_PATH/id_rsa"
        env:
          PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
      - name: Deploy to TestFlight/PGY
        run: |
          curl -F "file=@build/app/outputs/apk/prod/release/cruise-release-1.0.0.apk" -F "_api_key=${{ secrets.PGY_API_KEY }}" http://www.pgyer.com/apiv2/app/upload
        env:
          FLUTTER_ROOT: ${{ secrets.FLUTTER_ROOT }}
          APPLE_ID: ${{ secrets.APPLE_ID }}
          GIT_URL: ${{ secrets.GIT_URL }}
          PGY_USER_KEY: ${{ secrets.PGY_USER_KEY }}
          PGY_API_KEY: ${{ secrets.PGY_API_KEY }}
          TEAM_ID: ${{ secrets.TEAM_ID }}
          ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }}
          FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
          FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
          FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
          FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }}
          MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
          MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }}
          MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
          DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS: ${{ secrets.DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS }}


Solution 1:[1]

upgrade the android build tools and gradle version could fix it:

// legacy
classpath 'com.android.tools.build:gradle:3.5.1'

// new
classpath 'com.android.tools.build:gradle:4.0.1'

the gradle version(android/gradle/gradle-wrapper.properties) upgrade to 6.1.1:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip

Solution 2:[2]

Go to the Android SDK folder, look for NDK, delete content and build again.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dolphin
Solution 2 CuriousSuperhero