Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在管道上缓存lib?_Android_Continuous Integration_Bitbucket_Bitbucket Pipelines - Fatal编程技术网

Android 如何在管道上缓存lib?

Android 如何在管道上缓存lib?,android,continuous-integration,bitbucket,bitbucket-pipelines,Android,Continuous Integration,Bitbucket,Bitbucket Pipelines,这是我的android项目的bitbucket pipelines.yml文件: # This is a sample build configuration for Java (Gradle). # Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples. # Only use spaces to indent your .yml configuration. # ----- # You c

这是我的android项目的
bitbucket pipelines.yml
文件:

# This is a sample build configuration for Java (Gradle).
# Check our guides at https://confluence.atlassian.com/x/zd-5Mw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: java:8

pipelines:
  branches:
    '{master}':
    - step:
        caches:
        - gradle
        - android-sdk

        script:
        # Download and unzip android sdk
        - wget --quiet --output-document=android-sdk.zip https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
        - unzip -o -qq android-sdk.zip -d android-sdk

        # Define Android Home and add PATHs
        - export ANDROID_HOME="/opt/atlassian/pipelines/agent/build/android-sdk"
        - export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"

        # Download packages.
        - yes | sdkmanager "platform-tools"
        - yes | sdkmanager "platforms;android-19"
        - yes | sdkmanager "platforms;android-23"
        - yes | sdkmanager "platforms;android-28"
        - yes | sdkmanager "build-tools;27.0.3"
        - yes | sdkmanager "build-tools;28.0.3"
        - yes | sdkmanager "extras;android;m2repository"
        - yes | sdkmanager "extras;google;m2repository"
        - yes | sdkmanager "extras;google;instantapps"
        - yes | sdkmanager --licenses

        # Build apk
        - echo “Start default step”
        - # Add Android SDK license in the default file
        - mkdir "${ANDROID_HOME}/licenses" || true
        - echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > $ANDROID_HOME/licenses/android-sdk-license
        - echo "d56f5187479451eabf01fb78af6dfcb131a6481e" > $ANDROID_HOME/licenses/android-sdk-license

          # Build the app
        - chmod a+x gradlew
        - ./gradlew assembleDebug
        - echo "Amazing"


definitions:
  caches:
    android-sdk: android-sdk
    gradle: gradle
但当我重新运行脚本时,它总是下载libs进行构建:

Downloading https://services.gradle.org/distributions/gradle-4.4-all.zip
..............................................................................................
Unzipping /root/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4-all.zip to /root/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1
Set executable permissions for: /root/.gradle/wrapper/dists/gradle-4.4-all/9br9xq1tocpiv8o6njlyu5op1/gradle-4.4/bin/gradle
Starting a Gradle Daemon (subsequent builds will be faster)
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.4/gradle-3.1.4.pom
Download https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.61/kotlin-gradle-plugin-1.2.61.pom
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/bundletool/0.1.0-alpha01/bundletool-0.1.0-alpha01.pom
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle-core/3.1.4/gradle-core-3.1.4.pom

是否有任何方法可以避免为project重新下载LIB,可能存在缓存和解压缩它们的情况,如“android sdk”和“gradle”)?

管道总是从一个新的Docker容器开始。如果发现管道每次运行时都执行相同的容器设置,则应该考虑使用包含该设置的自己的图像。有关更多信息,请参阅(非特定于Android)。管道总是从一个新的Docker容器开始。如果发现管道每次运行时都执行相同的容器设置,则应该考虑使用包含该设置的自己的图像。有关更多信息,请参阅(非特定于Android)。