我发现每次Travis CI构建项目时,都必须再次下载所有SDK包,如平台工具,支持库,当前SDK等。
是否可以避免它并让Travis重新使用它第一次下载的内容?
我可能在我的.travis.yml文件中犯了一些错误,这里有一个副本
language: android
android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
- platform-tools
- tools
# The BuildTools version used by your project
- build-tools-23.0.2
# The SDK version used to compile your project
- android-23
# Additional components
- extra-android-support
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
- addon-google_apis-google-19
# Specify at least one system image,
# if you need to run emulator(s) during your tests
# - sys-img-armeabi-v7a-android-19
# - sys-img-x86-android-17
script:
- ./gradlew check
- ./gradlew test --continue
# - ./gradlew build connectedCheck
答案 0 :(得分:0)
为什么Travis CI每次下载都会下载所有内容?
我们谈论这个here,Travis-ci从S3下载缓存,因此缓存大型文件(例如Android SDK)没有显着的速度提升。
如何在Travis-ci缓存中包含Android SDK? (不推荐)
相关位在这里,您可以将任何您喜欢的文件添加到缓存中并知道他的路径:
cache:
directories:
- ${TRAVIS_BUILD_DIR}/gradle/caches/
- ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/
- ${TRAVIS_BUILD_DIR}/android-sdk/extras/ # please don't include sys-images
我之前做过,你可以看到代码in the link shared by @nicolas-f:
language: android
jdk: oraclejdk8
env:
global:
- GRADLE_USER_HOME=${TRAVIS_BUILD_DIR}/gradle
- ANDROID_HOME=${TRAVIS_BUILD_DIR}/android-sdk
- SDK=${TRAVIS_BUILD_DIR}/android-sdk
- PATH=${GRADLE_USER_HOME}/bin/:${SDK}/:${SDK}/tools/:${SDK}/platform-tools/:${PATH}
before_install:
- export OLD_SDK=/usr/local/android-sdk-24.0.2;
mkdir -p ${SDK};
cp -u -R ${OLD_SDK}/platforms ${SDK}/platforms;
cp -u -R ${OLD_SDK}/system-images ${SDK}/system-images;
cp -u -R ${OLD_SDK}/tools ${SDK}/tools
cache:
apt: true
directories:
- ${TRAVIS_BUILD_DIR}/gradle/caches/
- ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/
- ${TRAVIS_BUILD_DIR}/android-sdk/extras/
android:
components:
# Update Android SDK Tools
- tools
- platform-tools
- build-tools-23.0.2
- android-23
- add-on
- extra
script:
- ./gradlew check
使用ls
确认SDK路径未再次更改。
目前无需移动SDK,您需要更新其他内容,可能在tools
之后添加另一个platform-tools
,此代码已过时。