I'm getting error No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi. The solutions I found were to upgrade or downgrade NDK in Android Studio. However, I'm using Azure Pipeline and am not sure how to do that.

There were two runs, where one of them was successful, and the other one was failed. Both of them had a same commits and only differs by one day. The only difference between them was the agent and image version in Initialize Job task.

Success:

Starting: Initialize job
Agent name: 'Hosted Agent'
Agent machine name: 'fv-az394-23'
Current agent version: '2.192.0'
Operating System
Virtual Environment
Virtual Environment Provisioner
Current image version: '20210919.1'
Agent running as: 'vsts'
Prepare build directory.

Failed:

Starting: Initialize job
Agent name: 'Hosted Agent'
Agent machine name: 'fv-az216-247'
Current agent version: '2.193.0'
Operating System
Virtual Environment
Virtual Environment Provisioner
Current image version: '20210929.1'
Agent running as: 'vsts'
Prepare build directory.

I think the solution is either configuring the gradle (which I'm not sure which one to fix) or reconfigure NDK in MS hosted agent (which I'm not sure how).

Any advice? I'm not sure whether this is flutter (1.22.6) specific or android problem in general. However, I can build it just fine on my machine.

3

There are 3 best solutions below

0
On BEST ANSWER

As discussed in this github issue workaround, basically we need to add NDK version in app/build.gradle. The minimal solution would be:

android {
    compileSdkVersion 30
    ndkVersion "21.4.7075529"
    ...
}
0
On

I solved the same problem by adding this line into local.properties.

ndk.dir=C:\\Users\\**\\AppData\\Local\\Android\\sdk\\ndk\\24.**

** and 24.** = you need to find via your file folder.

0
On

I had the same issue. My pipeline was running perfectly over ubuntu-16.04 but recently Microsoft has removed the support fot ubuntu-16.04 and this NDK issue started appearning for ubuntu-latest and ubuntu-18. The main reason is that NDK 23 has different toolchain than the previous versions of NDK (22-), so the old version of AGP (Android Gradle Plugin) has not idea where to find the executables for different ABIs. Here is the workaround I have done.

   - task: Bash@3
      displayName: 'Install NDK'
      inputs:
        targetType: 'inline'
        script: '$ANDROID_HOME/tools/bin/sdkmanager --install "ndk;20.0.5594570"'
    - task: Bash@3
      displayName: 'Downloading NDK'
      inputs:
        targetType: 'inline'
        script: wget https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip -P $(Build.SourcesDirectory)
    - task: Bash@3
      displayName: 'Unzipping NDK'
      inputs:
        targetType: 'inline'
        script: unzip $(Build.SourcesDirectory)/android-ndk-r20b-linux-x86_64.zip
            
    - task: Bash@3
      displayName: 'copying NDK to NDK Variable'
      inputs:
        targetType: 'inline'
        script: cp -r $(Build.SourcesDirectory)/android-ndk-r20b/toolchains $ANDROID_NDK_LATEST_HOME; cp -r $(Build.SourcesDirectory)/android-ndk-r20b/toolchains $ANDROID_NDK_HOME