I'm trying to set up my CI for a Android project that uses some C++ code. As such I need the NDK that doesn't come pre-installed on Travis Android images. I'm currently achieving this by pulling the NDK myself, however my CI box is complaining about the CMake license not being accepted. The weird thing is that I thought this was included in the android-sdk-license which I am already including in my build. My travis YAML looks like this:
language: android
jdk:
- oraclejdk8
- oraclejdk9
android:
components:
- tools
- platform-tools
- tools
- build-tools-26.0.2
- android-26
- extra-android-m2repository
- extra-google-m2repository
- extra-android-support
- extra-google-google_play_services
- add-on
- extra
licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
before_script:
- wget https://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip
- unzip -qq android-ndk-r16b-linux-x86_64.zip
- export ANDROID_NDK_HOME=`pwd`/android-ndk-r16b
- export LOCAL_ANDROID_NDK_HOME="$ANDROID_NDK_HOME"
- export LOCAL_ANDROID_NDK_HOST_PLATFORM="linux-x86_64"
- export PATH=$PATH:${ANDROID_NDK_HOME}
- env
script: ./gradlew build jacocoTestReport
matrix:
fast_finish: true
allow_failures:
- jdk: oraclejdk9
notifications:
email: false
after_success:
— bash <(curl -s https://codecov.io/bash)
The license error can be seen at the bottom of the build here
This is currently working for me:
install:
- echo y | sdkmanager 'ndk-bundle'
- echo y | sdkmanager 'cmake;3.6.4111459'
- echo y | sdkmanager 'lldb;3.0'
My .travis.yml is available here.
Looks like the NDK samples use travis, maybe look there to see what's missing from your build: https://github.com/googlesamples/android-ndk/blob/master/.travis.yml
I didn't try it but perhaps it's similar to the constraint library related issue.
As explained here and here, use a workaround to solve license issues or directly download it:
is there any solution without workaround using export license?
Yes, you can use the new sdkmanager
to install the constraint library and accept the license:
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2"
- echo yes | sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"
In your case, check the correct version for cmake
like here and here, cmake;3.6.4111459
:
- sdkmanager --list || true
- echo yes | sdkmanager "cmake;3.6.4111459"
Otherwise, the missing component will be detected by gradle
and downloaded without accept it:
# Show version and download Gradle Wrapper if it's not already cached
- ./gradlew --version
# Clean project and download missing dependencies and components
- ./gradlew clean build
In that case, as explained here, you need to accept the license the first time via the workaround:
In your .travis.yml
file add:
before_install:
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
Do not forgot to accept all the licences on the main android
object:
android:
components:
# ...
licenses:
- android-sdk-license-.+
- '.+'
Before android script deprecation, you can accept all the licenses at the same time like this:
# THE SETUP STAGE
# ---------------
# If you comment out this section, Travis CI will install for you the components you define here.
# Check your project requirements and the components included by default on Travis-ci VM images.
# Check required: https://github.com/google/iosched/blob/master/doc/BUILDING.md
# Check defaults: http://docs.travis-ci.com/user/languages/android/#Pre-installed-components
android:
components:
# Check Android SDK tools: http://developer.android.com/tools/sdk/tools-notes.html
# Check Android SDK Platform-tools: http://developer.android.com/tools/revisions/platforms.html
# Comment the lines below if the latest revisions of Android SDK Tools are included by default.
# - tools
# - platform-tools
# ...
licenses:
# Check licenses: http://docs.travis-ci.com/user/languages/android/#Dealing-with-Licenses
# By default Travis will accept all the licenses, but it's also possible to define a white list:
# White list current android-sdk-license revision.
# - 'android-sdk-license-5be876d5'
# White list all android-sdk-license revisions.
# - 'android-sdk-license-.+'
# White list all the licenses.
- '.+'
I think that if you remove licenses section, 'white list all the licenses' - '.+'
is applied by default.