Gitlab CI with Android NDK

I am trying to implement gitlab CI in my android project. I have configured the .gitlab-ci.yml following official documentation. This is how my .gitlab-ci.yml looks like,

image: openjdk:8-jdk
    variables:
  ANDROID_COMPILE_SDK: "29"
  ANDROID_BUILD_TOOLS: "28.0.3"
  ANDROID_SDK_TOOLS:   "4333796"

before_script:
  - apt-get --quiet update --yes
  - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
  - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-${ANDROID_SDK_TOOLS}.zip
  - unzip -d android-sdk-linux android-sdk.zip
  - echo y | android-sdk-linux/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" >/dev/null
  - echo y | android-sdk-linux/tools/bin/sdkmanager "platform-tools" >/dev/null
  - echo y | android-sdk-linux/tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}" >/dev/null
  - export ANDROID_HOME=$PWD/android-sdk-linux
  - export ANDROID_NDK_HOME=${ANDROID_HOME}/ndk/22.0.7026061/
  - export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
  - echo "sdk.dir=${ANDROID_HOME}" >> local.properties
  - echo "ndk.dir=${ANDROID_NDK_HOME}" >> local.properties
  - chmod +x ./gradlew
  - set +o pipefail
  - yes | android-sdk-linux/tools/bin/sdkmanager --licenses
  - set -o pipefail

stages:
  - build
  - test

assembleDebug:
  stage: build
  script:
    - ./gradlew assembleDebug
  artifacts:
    paths:
      - app/build/outputs/apk/debug/

debugTests:
  stage: test
  script:
    - ./gradlew -Pci --console=plain :app:testDebug
`

but it seems to failing all the time with the exception

* What went wrong:
A problem occurred configuring project ':app'.
java.lang.NullPointerException (no error message) 

Also, I get warning,

"Install NDK (revision: 22.0.7026061)" complete.
"Install NDK (revision: 22.0.7026061)" finished.
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory.  It is currently set to 
 /builds/muhammad.asad2/asad-gitlab-cicd/android-sdk-linux/ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to 
remove this warning.

Any help or guidance would be highly appreciated, also, if any link to a sample .gitlab-ci.yml which has NDK configured would be great.

This may (or may not) help. One of my projects uses Android NDK. Here is my script for setting stuff up.

This is the .gitlab-ci.yml part that calls the script and builds my project.

image

Yes. The SDK tools and NDK versions are old. Don’t judge me :slight_smile:

image

can you provide the link of the config?