Android NDK on Unix is incompatible with Android Build tools 3.6.0

In this pull request I tried to update our build tools and gradle distribution but ran into issues with the installed NDK versions.

When not specifying an NDK version (how the project has functioned up to now) it failed on the linux runner with

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

When specifying “21.0.6113669” it failed on the MacOs runner with

No version of NDK matched the requested version 21.0.6113669. Versions available locally: 18.1.5063045, 18.1.5063045

When specifying “18.1.5063045” it failed on the unix runner with

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

I don’t know much about ndk versions or the update schedule for the runners. Will this problem be resolved soon or will I have to try and install the NDK in my workflow?


Yeah I am seeing this failure here as well:

Not sure what I should do about it…

I’m also seeing this issue in several projects when using Android Gradle plugin 3.6.0. When trying to explicitly set the ndk version (so it won’t auto-detect an _older_ version), it’ll fail with this error:

> Failed to install the following SDK components:
      cmake; CMake
  The SDK directory is not writable (/usr/local/lib/android/sdk)

I can not make sure whether this issue is related to Github Actions or Android.

Could you please try to build your project in your local machine, when build with Android Build tools 3.6.0, will you get the same error message? 

Indeed the Android NDK installed in the hosted ubuntu machine is 21.0.6113669.  And the version in MacOS machine is 18.1.5063045. You could check the software installed in github hosted runner from this link.


Out of curiosity how do you explicitly set the ndk version?

In build.gradle in the android closure ndkVersion = "20.whatever"

Ahh, like that. Ok. I thought you meant in the GitHub Action workflow. Gotcha

I ran a full

gradlew assemble

on my branch and it built perfectly fine on my local machine.

I do not have a NDK installation that I am aware of:

I do not use the NDK in any of my projects but do consume some .so libraries from 3rd party dependencies.

Seeing as how the inital build succeeds on MacOs runners I would think downgrading the Unix runners NDK version to the same would resolve my issue but I am totally unaware of further reaching impacts.

Edit: some output from the task that succeds locally for me but fails on the runners

> Task :custom:stripCustomexampleDebugDebugSymbols
WARNING: Compatible side by side NDK version was not found. Default is 20.0.5594570.
Compatible side by side NDK version was not found. Default is 20.0.5594570.
Unable to strip the following libraries, packaging them as they are:,,,,,,,

I don’t care about the stripping of debug symbols because I am consuming release artifacts that should have already undergone this process - or so I assume.

I could introduce a gradle property 

gradlew assemble -Pndk="20..."

to my commands in the actions to pass along these parameters but that seems very much like a hack to me.

I am happy to wait for a better solution for the time being

1 Like

I have gone further down the rabbit hole and it seems like this will be fixed by google.

If you actually use the NDK then the NDK will be auto downloaded, link

If you have native libs packaged with your apk from a 3rd party dependency like me and don’t need the NDK then they will be moving strip binaries to the build tools, link

A bit annoyingly the sdkmanager is not installed on the unix runner, github issue
If it were then installing the ndk would be as simple as

- name: Install ndk
        run: sdkmanager 'ndk;20.0.5594570'

I could not access to the two google issue links you provided as lacking of google account. 

I found a way to install sdkmanager to hosted ubuntu runner. 

- name: install sdkmanager
      working-directory: /home/runner
      run: |
         java -version
         export PATH=/home/runner/tools:/home/runner/tools/bin:$PATH
         sdkmanager 'ndk;20.0.5594570'
         sdkmanager --list

When I run sdkmanager --list directly without  sdkmanager ‘ndk;20.0.5594570’  , I also see 

sdkmanager list.png

To be honest, I am not good at Android , I am not sure why you get that message even if the specific version is already installed. 

Hope the scripts to install sdkmanager could help you a bit. 

@macgills I was able to fix the issue by adding the version of ndk in the concerned gradle file for which the given execution fails. Can you please let us know how did you overcome this problem or still facing it?

@s-ayush2903 we resolved this issue on our project months ago. With the release of 4.1 we no longer will have to specify the ndk with android-emulator-runner action which thankfully added the functionality to specify ndk version

So, If I’m not using android-emulator-runner from reactive circus, then I’ll have to specify ndkVersion. right?

Not if you use >=4.1 of the android gradle plugin, it would be handled by it. Below 4.1 the ndk would have to be specified either in the action or in the gradle files and as mentioned further up this thread to match with what is available in the runners by default, there would need to be a conditional based on the runner environment to switch between the 2 versions that are available on the respective runners so compilation does not fail.