我需要在我的Android项目中集成一个持续集成系统,我发现CodeShip是一个很好的选择,因此我创建并配置了一个项目,以使用以下脚本来编译我的Android应用程序:
# Install java 8
jdk_switcher home oraclejdk8
jdk_switcher use oraclejdk8
export JAVA8_HOME=/usr/lib/jvm/java-8-oracle
export BUILD_TOOLS_VERSION=23.0.3
export ANDROID_SDK=24
export ANDROID_SDK_REV=24.4.1
#
# Install android sdk
export SDK_TAR=android-sdk_r$ANDROID_SDK_REV-linux
wget "http://dl.google.com/android/$SDK_TAR.tgz"
tar xvzf "$SDK_TAR.tgz"
rm "$SDK_TAR.tgz"
export ANDROID_HOME=$PWD/android-sdk-linux
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
(while sleep 3; do echo "y"; done) | $ANDROID_HOME/tools/android update sdk -u
echo "y" | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-$BUILD_TOOLS_VERSION > step1.log
echo "y" | android update sdk --no-ui --all --filter extra-android-m2repository,extra-android-support,extra-google-analytics_sdk_v2,extra-google-google_play_services_froyo,extra-google-google_play_services,extra-google-m2repository > step2.log
echo "y" | android update sdk --no-ui --all --filter android-$ANDROID_SDK,sysimg-$ANDROID_SDK,addon-google_apis-google-$ANDROID_SDK > step3.log
#
# Setup gradle
touch local.properties
echo "sdk.dir=$ANDROID_HOME" >> local.properties
chmod u+x ./gradlew
#
# Build
./gradlew assembleDevelop
当我推送存储库并启动编译时,在编译过程中会发生以下错误:
Warning: License for package Android SDK Build-Tools 27.0.3 not accepted.
FAILURE: Build failed with an exception.
occurred configuring project ':app'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
build-tools;27.0.3 Android SDK Build-Tools 27.0.3
To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
Using Android SDK: /home/rof/clone/android-sdk-linux
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 20s
原则上,行echo "and" | android update sdk --no-ui --all - filter tools, platform-tools, build-tools- $ BUILD_TOOLS_VERSION> step1.log
应该可以解决此问题。有人可以告诉我脚本中缺少的内容以成功执行编译。
谢谢!
答案 0 :(得分:1)
您的基础架构提供商(即CodeShip)不为该级别的SDK构建工具提供支持。也许与他们联系可能会有所帮助。
对于在自己的PC上工作时遇到基于Android的错误的人:-
将目录更改为C:\ Users \ YOURPCNAME \ tools \ bin 然后在这里运行sdkmanager --licenses 接受许可,您将很方便