TravisCI中的NDK,CMake和Android
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TravisCI中的NDK,CMake和Android相关的知识,希望对你有一定的参考价值。
我正在尝试为使用某些C ++代码的android项目设置CI。因此,我需要预先安装在Travis Android映像上的NDK。我现在正在通过自己拉NDK实现这一点,但我的CI盒子抱怨CMake许可证未被接受。奇怪的是,我认为这包含在我已经包含在我的构建中的android-sdk-license中。我的travis YAML看起来像这样:
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)
许可证错误可以在构建here的底部看到
目前这对我有用:
install:
- echo y | sdkmanager 'ndk-bundle'
- echo y | sdkmanager 'cmake;3.6.4111459'
- echo y | sdkmanager 'lldb;3.0'
我的.travis.yml可用here。
看起来像NDK样本使用travis,也许看那里看你的构建中缺少什么:https://github.com/googlesamples/android-ndk/blob/master/.travis.yml
我没有尝试过,但也许它与约束库相关的问题类似。
如here和here所述,使用解决方法解决许可证问题或直接下载:
有没有使用出口许可证的解决方法?
是的,你可以使用新的sdkmanager
来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"
在您的情况下,请检查cmake
和here,here的cmake;3.6.4111459
的正确版本:
- sdkmanager --list || true
- echo yes | sdkmanager "cmake;3.6.4111459"
否则,gradle
将检测到缺失的组件并在不接受的情况下下载:
# 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
在这种情况下,如here所述,您需要通过变通方法第一次接受许可:
在你的
.travis.yml
文件中添加:before_install: - mkdir "$ANDROID_HOME/licenses" || true - echo -e " 8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license" - echo -e " 84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
不要忘记接受主要
android
对象上的所有许可证:android: components: # ... licenses: - android-sdk-license-.+ - '.+'
在Android脚本弃用之前,您可以像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.
- '.+'
我认为,如果删除许可证部分,默认情况下会应用“白名单所有许可证”- '.+'
。
以上是关于TravisCI中的NDK,CMake和Android的主要内容,如果未能解决你的问题,请参考以下文章
Android NDK 开发CMake 中查找链接 Android 自带动态库位置说明 ( ndk-bundleplatformsandroid-29arch-armusrlib )
Android NDK 开发CMake 中查找链接 Android 自带动态库位置说明 ( ndk-bundleplatformsandroid-29arch-armusrlib )