【问题标题】:sdk location not found when running CI pipeline but build works locally运行 CI 管道时找不到 sdk 位置,但在本地构建工作
【发布时间】:2021-04-29 16:38:51
【问题描述】:

当我使用 Gradle 在本地构建这个项目时,我获得了成功的构建。但是,在我的 .yml 文件中,CI 管道中的构建失败:

image: java:8-jdk

stages:
  - build
  - test
  - code-analysis

before_script:
  #  - echo `pwd` # debug
  #  - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
  - export GRADLE_USER_HOME=`pwd`/.gradle
  - chmod +x gradlew

cache:
  paths:
    - .gradle/wrapper
    - .gradle/caches

build:
  stage: build
  script:
    - ./gradlew clean build

test:
  stage: test
  script:
    - ./gradlew test

lint:
  stage: code-analysis
  script:
    ./gradlew lint

checkstyle:
  stage: code-analysis
  script:
    ./gradlew checkstyle

pmd:
  stage: code-analysis
  script:
    ./gradlew pmd

这是管道构建阶段的错误消息:

FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:assemble'.
> Could not create task ':app:assembleRelease'.
   > Could not create task ':app:lintVitalRelease'.
      > SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file.

我该如何解决这个问题?我需要全局设置 sdk 位置吗?我需要清除缓存吗?如果是这样,我如何在 .yml 文件中实现这一点?

【问题讨论】:

    标签: java android-studio gradle sdk continuous-integration


    【解决方案1】:

    现在您使用的是 java-8 jdk 映像,并且没有安装 android sdk。有两种方法可以让 docker 镜像安装所需的一切:

    • 您创建我们自己的 docker 映像
    • 您使用的是开源 docker 映像

    解决当前问题的最快方法是将image: java:8-jdk 替换为image: javiersantos/android-ci:28.0.3

    【讨论】:

      猜你喜欢
      • 2020-07-23
      • 2021-04-12
      • 2020-11-09
      • 1970-01-01
      • 1970-01-01
      • 2021-05-22
      • 1970-01-01
      • 2022-08-14
      • 1970-01-01
      相关资源
      最近更新 更多