尝试在CircleCI上构建项目时,在gradle构建期间会发生以下错误。此问题的原因是什么?我正在运行CircleCI 2.0。
失败:构建失败,发生异常。
出了什么问题:配置项目':app'时发生问题。
找不到SDK位置。在local.properties文件中使用sdk.dir或使用ANDROID_HOME环境变量来定义位置。
尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。
在https://help.gradle.org上获得更多帮助
18秒内失败,代码1退出
这是我的config.yml的样子:
# Java Gradle CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-java/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
working_directory: ~/repo
environment:
# Customize the JVM maximum heap limit
JVM_OPTS: -Xmx3200m
TERM: dumb
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "build.gradle" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: gradle dependencies
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "build.gradle" }}
# run tests!
- run: gradle test
Run Code Online (Sandbox Code Playgroud)
CircleCI for Android提供了一个示例配置,该配置可解决您遇到的SDK问题。我不确定为什么在设置要遵循的新项目时他们不显示此选项。
基本上,当您建立一个新项目以遵循CircleCI时,您可能选择了Gradle(Java)选项。这并不是专门针对Android,因此这就是它抱怨缺少SDK的原因。
上面链接的示例配置如下所示(最重要的部分是指定的docker映像,CircleCI文档对每一行的工作都有很好的解释):
version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-25-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum
"app/build.gradle" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum
"app/build.gradle" }}
- run:
name: Run Tests
command: ./gradlew lint test
- store_artifacts:
path: app/build/reports
destination: reports
- store_test_results:
path: app/build/test-results
Run Code Online (Sandbox Code Playgroud)
希望您早日建成!
| 归档时间: |
|
| 查看次数: |
1857 次 |
| 最近记录: |