不建议缓存SDK工具,但是可以这样做。我过去曾经这样做过,我会找一个示例。
同时,请删除这些不必要的行以加快速度,并告诉我它是否有效。
- extra
- add-on
- extra-google-google_play_services
- extra-android-support
- addon-google_apis-google-$ANDROID_API_LEVEL
- sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL
您只需要安装存储库、一个模拟器和特定组件,而不是像这样的列表:
- add-on
- extra
Installing Archives:
Preparing to install archives
Downloading GPU Debugging tools, revision 1.0.3
Installing GPU Debugging tools, revision 1.0.3
Installed GPU Debugging tools, revision 1.0.3
Downloading Android Support Repository, revision 29
Installing Android Support Repository, revision 29
Installed Android Support Repository, revision 29
Downloading Android Support Library, revision 23.2.1
Installing Android Support Library, revision 23.2.1
Installed Android Support Library, revision 23.2.1
Downloading Google AdMob Ads SDK, revision 11 (Obsolete)
Installing Google AdMob Ads SDK, revision 11 (Obsolete)
Installed Google AdMob Ads SDK, revision 11 (Obsolete)
Downloading Google Analytics App Tracking SDK, revision 3 (Obsolete)
Installing Google Analytics App Tracking SDK, revision 3 (Obsolete)
Installed Google Analytics App Tracking SDK, revision 3 (Obsolete)
Downloading Android Auto Desktop Head Unit emulator, revision 1.1
Installing Android Auto Desktop Head Unit emulator, revision 1.1
Installed Android Auto Desktop Head Unit emulator, revision 1.1
Downloading Google Cloud Messaging for Android Library, revision 3 (Obsolete)
Installing Google Cloud Messaging for Android Library, revision 3 (Obsolete)
Installed Google Cloud Messaging for Android Library, revision 3 (Obsolete)
Downloading Google Play services for Froyo, revision 12 (Obsolete)
Installing Google Play services for Froyo, revision 12 (Obsolete)
Installed Google Play services for Froyo, revision 12 (Obsolete)
Downloading Google Play services, revision 29
Installing Google Play services, revision 29
Installed Google Play services, revision 29
Downloading Google Repository, revision 25
Installing Google Repository, revision 25
Installed Google Repository, revision 25
Downloading Google Play APK Expansion library, revision 1
Installing Google Play APK Expansion library, revision 1
Installed Google Play APK Expansion library, revision 1
Downloading Google Play Licensing Library, revision 1
Installing Google Play Licensing Library, revision 1
Installed Google Play Licensing Library, revision 1
Downloading Google Play Billing Library, revision 5
Installing Google Play Billing Library, revision 5
Installed Google Play Billing Library, revision 5
Downloading Android Auto API Simulators, revision 1
Installing Android Auto API Simulators, revision 1
Installed Android Auto API Simulators, revision 1
Downloading Google Web Driver, revision 2
Installing Google Web Driver, revision 2
Installed Google Web Driver, revision 2
Done. 15 packages installed.
November 19, 2013
Do you accept the license 'google-gdk-license-35dc2951' [y/n]: y
Installing Archives:
Preparing to install archives
Downloading Google APIs, Android API 23, revision 1
Installing Google APIs, Android API 23, revision 1
Installed Google APIs, Android API 23, revision 1
Downloading Google APIs, Android API 21, revision 1
Installing Google APIs, Android API 21, revision 1
Installed Google APIs, Android API 21, revision 1
Downloading Google APIs (x86 System Image), Android API 19, revision 18
Installing Google APIs (x86 System Image), Android API 19, revision 18
Installed Google APIs (x86 System Image), Android API 19, revision 18
Downloading Google APIs, Android API 19, revision 18
Installing Google APIs, Android API 19, revision 18
Installed Google APIs, Android API 19, revision 18
Downloading Glass Development Kit Preview, Android API 19, revision 11
Installing Glass Development Kit Preview, Android API 19, revision 11
Installed Glass Development Kit Preview, Android API 19, revision 11
Downloading Google APIs, Android API 18, revision 4
Installing Google APIs, Android API 18, revision 4
Installed Google APIs, Android API 18, revision 4
Downloading Google APIs, Android API 17, revision 4
Installing Google APIs, Android API 17, revision 4
Installed Google APIs, Android API 17, revision 4
Downloading Google APIs, Android API 16, revision 4
Installing Google APIs, Android API 16, revision 4
Installed Google APIs, Android API 16, revision 4
Downloading Google APIs, Android API 15, revision 3
Installing Google APIs, Android API 15, revision 3
Installed Google APIs, Android API 15, revision 3
Downloading Google APIs, Android API 10, revision 2 (Obsolete)
Installing Google APIs, Android API 10, revision 2 (Obsolete)
Installed Google APIs, Android API 10, revision 2 (Obsolete)
更新: 我发现了这个构建,在其中我使用自定义路径缓存SDK工具额外内容,像这样:
cache:
apt: true
directories:
- ${TRAVIS_BUILD_DIR}/gradle/caches/
- ${TRAVIS_BUILD_DIR}/gradle/wrapper/dists/
- ${TRAVIS_BUILD_DIR}/android-sdk/extras/
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:
- echo "WARNING delete this when fixed"; export OLD_SDK=/usr/local/android-sdk-23.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 || echo "CP ERROR"
你不需要这样做,直接将默认路径保存到缓存中,该路径是存储库所在的位置:
/usr/local/android-sdk/extras
您 不需要 将完整的 SDK 工具和所有系统映像保存到缓存中。
缓存的目的是使安装特定语言依赖项变得更加容易和快速,因此与 Bundler、pip、Composer、npm、Gradle、Maven 等工具相关的所有内容都应该放入缓存中。
快速安装但下载慢的大文件不会从缓存中受益,因为它们从缓存中下载的时间与从原始源下载的时间一样长:
- Android SDKs
- Debian 包
- JDK 包
- 编译后的二进制文件
默认环境变量:
TRAVIS_BUILD_DIR
:在工作者上已复制正在构建的存储库的目录的绝对路径。