非淡泊无以明志,非宁静无以致远。这篇文章主要讲述TravisCI中的NDK,CMake和Android相关的知识,希望能为你提供帮助。
我正在尝试为使用某些C ++代码的android项目设置CI。因此,我需要预先安装在Travis Android映像上的NDK。我现在正在通过自己拉NDK实现这一点,但我的CI盒子抱怨CMake许可证未被接受。奇怪的是,我认为这包含在我已经包含在我的构建中的android-sdk-license中。我的travis YAML看起来像这样:
language: androidjdk:
- oraclejdk8
- oraclejdk9android:
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
- extralicenses:
- '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}
- envscript: ./gradlew build jacocoTestReportmatrix:
fast_finish: true
allow_failures:
- jdk: oraclejdk9notifications:
email: falseafter_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所述,您需要通过变通方法第一次接受许可:
在你的在Android脚本弃用之前,您可以像this一样同时接受所有许可证:.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-.+ - '.+'
# 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-componentsandroid:
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】我认为,如果删除许可证部分,默认情况下会应用“白名单所有许可证”
- '.+'
。推荐阅读
- 从.aar文件Android中提取代码
- 如何使用cmake和Android NDK在C ++中加载线程支持
- 不构建时Android Studio高CPU使用率
- Baresip与android
- Android NDK - 在没有Android Studio的情况下构建本机库
- Android Studio上的Cocos2d-x - 未列出新的CPP文件
- Android Studio外部本机构建预编译头
- 如何向android shell用户授予android.permission.RECORD_AUDIO权限()
- 是否有可能改变Android中蓝牙传输的频率(也许通过NDK?)