草庐IT

android - 在 Travis CI 中缓存 Android SDK

coder 2023-12-03 原文

我几乎没有在其上设置 Travis CI 的开源库。它们运行良好,除了检查构建需要 25 分钟以上的时间。大部分时间浪费在下载依赖和Android SDK平台上。

目前我的 .travis.yml 中有以下内容

language: android
jdk:
  - oraclejdk8
before_install:
- chmod +x gradlew
env:
  global:
   - ANDROID_API_LEVEL=24
   - EMULATOR_API_LEVEL=21
   - ANDROID_BUILD_TOOLS_VERSION=24.0.1
   - ANDROID_ABI=google_apis/armeabi-v7a
   - ADB_INSTALL_TIMEOUT=20 # minutes (2 minutes by default)

android:
  components:
    - tools
    - tools
    - platform-tools
    - build-tools-$ANDROID_BUILD_TOOLS_VERSION
    - android-$ANDROID_API_LEVEL
    - android-$EMULATOR_API_LEVEL
    - extra
    - add-on
    - extra-google-m2repository
    - extra-android-m2repository
    # Google Play Services
    - extra-google-google_play_services
    # Support library
    - extra-android-support

    - addon-google_apis-google-$ANDROID_API_LEVEL
    - addon-google_apis-google-$EMULATOR_API_LEVEL

    - sys-img-armeabi-v7a-addon-google_apis-google-$ANDROID_API_LEVEL
    - sys-img-armeabi-v7a-addon-google_apis-google-$EMULATOR_API_LEVEL

before_cache:
  - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
  directories:
    - $HOME/.gradle/wrapper
    - $HOME/.gradle/native
    - $HOME/.gradle/daemon
    - $HOME/.gradle/caches/jars-1
    - $HOME/.gradle/caches/2.3

before_script:
  - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
  - emulator -avd test -no-skin -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &

script:
  - gradle clean check

如您所见,我已经缓存了几个 gradle 目录,但它仍然没有缓存 Android SDK 平台。我确信我遗漏了一些仍需要缓存的目录。

有什么方法可以通过缓存这些 SDK 平台和依赖项来加快构建速度?

最佳答案

不推荐使用缓存SDK工具,但可以,我以前用过,我会搜索示例

同时,请删除这些不必要的行以加快速度,如果可行请告诉我。

    - extra
    - add-on
    # Google Play Services
    - extra-google-google_play_services
    # Support library
    - 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)

更新:我找到了this build我使用如下自定义路径缓存 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

don't want将完整的 sdk 工具保存到缓存,包括所有系统图像。

The cache’s purpose is to make installing language-specific dependencies easy and fast, so everything related to tools like Bundler, pip, Composer, npm, Gradle, Maven, is what should go into the cache.

Large files that are quick to install but slow to download do not benefit from caching, as they take as long to download from the cache as from the original source:

  • Android SDKs
  • Debian packages
  • JDK packages
  • Compiled binaries

Default environment variables :

TRAVIS_BUILD_DIR: The absolute path to the directory where the repository being built has been copied on the worker.

关于android - 在 Travis CI 中缓存 Android SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40295515/

有关android - 在 Travis CI 中缓存 Android SDK的更多相关文章

  1. ruby - 如何在 Ubuntu 中清除 Ruby Phusion Passenger 的缓存? - 2

    我试过重新启动apache,缓存的页面仍然出现,所以一定有一个文件夹在某个地方。我没有“公共(public)/缓存”,那么我还应该查看哪些其他地方?是否有一个URL标志也可以触发此效果? 最佳答案 您需要触摸一个文件才能清除phusion,例如:touch/webapps/mycook/tmp/restart.txt参见docs 关于ruby-如何在Ubuntu中清除RubyPhusionPassenger的缓存?,我们在StackOverflow上找到一个类似的问题:

  2. ruby-on-rails - Ruby on Rails 计数器缓存错误 - 2

    尝试在我的RoR应用程序中实现计数器缓存列时出现错误Unknownkey(s):counter_cache。我在这个问题中实现了模型关联:Modelassociationquestion这是我的迁移:classAddVideoVotesCountToVideos0Video.reset_column_informationVideo.find(:all).eachdo|p|p.update_attributes:videos_votes_count,p.video_votes.lengthendenddefself.downremove_column:videos,:video_vot

  3. 安卓apk修改(Android反编译apk) - 2

    最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路

  4. ruby-on-rails - bundle 安装尝试使用缓存文件 - 2

    当我尝试进行bundle安装时,我的gem_path和gem_home指向/usr/local/rvm/gems/我没有写入权限,并且由于权限无效而失败。因此,我已将两个路径都更改为我具有写入权限的本地目录。这样做时,我进行了bundle安装,我得到:bruno@test6:~$bundleinstallFetchinggemmetadatafromhttps://rubygems.org/.........Fetchinggemmetadatafromhttps://rubygems.org/..Bundler::GemspecError:Couldnotreadgemat/afs/

  5. ruby-on-rails - Heroku Action 缓存似乎不起作用 - 2

    我一直在Heroku上尝试不同的缓存策略,并添加了他们的memcached附加组件,目的是为我的应用程序添加Action缓存。但是,当我在我当前的应用程序上查看Rails.cache.stats时(安装了memcached并使用dalligem),在执行应该缓存的操作后,我得到current和total_items为0。在Controller的顶部,我想缓存我有的Action:caches_action:show此外,我修改了我的环境配置(对于在Heroku上运行的配置)config.cache_store=:dalli_store我是否可以查看其他一些统计数据,看看它是否有效或我做错

  6. ruby-on-rails - rails expire_page 没有删除缓存的文件 - 2

    我有一个具有页面缓存的ControllerAction,我制作了一个清扫程序,它使用Controller和指定的Action调用expire_page...Controller操作呈现一个js.erb模板,所以我试图确保expire_page删除public/javascripts中的.js文件,但它没有这样做。classJavascriptsController"javascripts",:action=>"lol",:format=>'js')endend...所以,我访问javascripts/lol.js并呈现我的模板。我验证了public/javascripts/lol.js

  7. ruby-on-rails - rails 3 缓存 : expire action for named route - 2

    我的Controller有这个:caches_action:render_ticker_for_channel,:expires_in=>30.seconds在我的路由文件中我有这个:match'/render_c_t/:channel_id'=>'render#render_ticker_for_channel',:as=>:render_channel_ticker在日志文件中我看到了这个:Writefragmentviews/mcr3.dev/render_c_t/63(11.6ms)我如何手动使它过期?我需要从与渲染Controller不同的Controller使它过期,但即使

  8. ruby - 更新 gem 时 Docker 包安装缓存问题 - 2

    我在开发和生产中都使用docker,真正困扰我的一件事是docker缓存的简单性。我的ruby​​应用程序需要bundleinstall来安装依赖项,因此我从以下Dockerfile开始:添加GemfileGemfile添加Gemfile.lockGemfile.lock运行bundleinstall--path/root/bundle所有依赖项都被缓存,并且在我添加新gem之前效果很好。即使我添加的gem只有0.5MB,从头开始安装所有应用程序gem仍然需要10-15分钟。由于依赖项文件夹的大小(大约300MB),然后再花10分钟来部署它。我在node_modules和npm上遇到了

  9. ruby-on-rails - 在缓存中找不到 StaleElementReference 错误元素 - 2

    我正在使用Capybara2.1和Ruby1.9.3,使用selenium驱动程序(带有Minitest和测试单元)来测试网络应用程序。我正在努力解决StaleElementReferenceException问题。我已经看到很多关于该主题的讨论,但我无法找到解决我所面临问题的方法。所以基本上,我试图使用以下代码在我的页面上找到所有分页元素:pagination_elements=page.all('.paginationa')然后我对这些元素做一些断言,例如:pagination_elements.first.must_have_content('1')在这些断言之后,我通过单击下一

  10. 最强Http缓存策略之强缓存和协商缓存的详解与应用实例 - 2

    HTTP缓存是指浏览器或者代理服务器将已经请求过的资源保存到本地,以便下次请求时能够直接从缓存中获取资源,从而减少网络请求次数,提高网页的加载速度和用户体验。缓存分为强缓存和协商缓存两种模式。一.强缓存强缓存是指浏览器直接从本地缓存中获取资源,而不需要向web服务器发出网络请求。这是因为浏览器在第一次请求资源时,服务器会在响应头中添加相关缓存的响应头,以表明该资源的缓存策略。常见的强缓存响应头如下所述:Cache-ControlCache-Control响应头是用于控制强制缓存和协商缓存的缓存策略。该响应头中的指令如下:max-age:指定该资源在本地缓存的最长有效时间,以秒为单位。例如:Ca

随机推荐