我已经在很多地方搜索过,即使是在Travis CI文档页面中,但我无法找到解决问题的方法。问题是 - 我已经在Travis CI上设置了一个Android项目,工作正常。现在,我有一些要求,我需要为我的项目编译一些本机文件。在我的本地计算机中,设置完全正常,因为我安装了SDK
和NDK
。当我推动代码时,特拉维斯抱怨NDK
。所以,我找了如何为特拉维斯设置 NDK 。我按照以下链接---
https://github.com/googlesamples/android-ndk/blob/master/.travis.yml
Travis: how to know android sdk/ndk path?
https://github.com/travis-ci/travis-ci/issues/5395
但以上都没有奏效。我的travis.yml
文件位于下方 -
# which language/platform is used
language: android
# JDK version
jdk:
- oraclejdk8
# root permission required?
sudo: required
dist: precise
# Environment variables
env:
global:
- BRANCH_NAME=$TRAVIS_BRANCH
# android components required to build code
android:
components:
- tools
- platform-tools
- build-tools-25.0.3
- android-24
- extra-android-m2repository
- extra-google-m2repository
- extra-google-google_play_services
# clean up old stuff before we get started
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
# cache directories to use
cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
# Configurations to set up Android NDK
before_install:
- rm -fr $HOME/android-ndk-r16b
- curl -L http://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip -O
- unzip -oq android-ndk-r16b-linux-x86_64.zip
- rm android-ndk-r16b-linux-x86_64.zip
- export ANDROID_NDK_HOME=$HOME/android-ndk-r16b
- export PATH=$PATH:${ANDROID_NDK_HOME}
# Build script - which configs and creates the builds
script: "./my_script.sh"
通过此设置,Travis CI识别出 NDK ,但在运行我的构建脚本时,它无法找到它。以下是我的Travis构建的日志 -
android.install
Installing Android dependencies
creating directory /home/travis/.gradle/caches
adding /home/travis/.gradle/wrapper to cache
creating directory /home/travis/.gradle/wrapper
$ java -Xmx32m -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
$ javac -J-Xmx32m -version
javac 1.8.0_111
before_install.1
$ rm -fr $HOME/android-ndk-r16b
before_install.2
$ curl -L http://dl.google.com/android/repository/android-ndk-r16b-linux-x86_64.zip -O
before_install.3
$ unzip -oq android-ndk-r16b-linux-x86_64.zip
before_install.4
$ rm android-ndk-r16b-linux-x86_64.zip
before_install.5
$ export ANDROID_NDK_HOME=$HOME/android-ndk-r16b
before_install.6
$ export PATH=$PATH:${ANDROID_NDK_HOME}
$ ./build_cc_app.sh
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/3.3/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing
Parallel execution with configuration on demand is an incubating feature.
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 /home/travis/android-ndk-r16b.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
NDK is missing a "platforms" directory.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':client'.
> NDK not configured. /home/travis/android-ndk-r16b
Download it with SDK manager.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 29.479 secs
答案 0 :(得分:0)
错误消息显示它缺少platforms
目录。您可以通过请求在存储库上启用调试来进一步调查:
此功能适用于私人存储库和公共存储库 已启用该功能的存储库。拥有该功能 已启用公共存储库,请发送电子邮件至 support@travis-ci.com指出哪些。推送访问 存储库也是必需的。
我发现Travis很快回复,但您还需要设置命令行客户端:
答案 1 :(得分:0)
因此,经过Travis CI构建的大量麻烦和大量调试会议后,我找到了解决此问题的方法。显然,默认的android
工具链在其NDK
目录中搜索SDK
。由于无法找到,它正在抱怨NDK
。所以,我不得不使用默认工具链来获取NDK
。以下是我的.travis.yml
文件的快照,其中指出了我为解决此问题所做的更改。
要找到我添加tools
两次的答案,您可以参考此link。请参阅下面的图片,找出文档的哪个部分来引用答案。
因此,正如Travis CI文档中提到的那样,当我们要构建SDK
级别 24 的Android项目时,我们需要使用{{1在tools
脚本中两次选项。
然后当我使用yml
构建我的原生文件时,我只需在ndk-build
脚本中添加以下部分。
yml
要记住一件事。我使用# Configurations to set up Android NDK
before_install:
- echo y | sdkmanager "ndk-bundle"
语言进行原生项目。如果您使用的是C
,则可能需要为此安装C++
。下面是代码 -
Cmake