每次Circle CI运行./gradlew assembleDebug
部分时,它总是失败。我不知道问题出在哪里,但是我尝试了很多方式,例如在有无daemon
或没有建立gradle.properties
的情况下运行它。我一直在Google和SO上寻找答案,但仍然找不到合适的答案。
这是错误
Gradle构建守护程序意外消失(它可能已被杀死或崩溃)
这是我的 config.yml
version: 2
references:
## Workspaces
workspace: &workspace
~/src
save_workspace_artifacts: &save_workspace_artifacts
store_artifacts:
path: outputs/outputs/apk
attach_workspace_artifacts: &attach_workspace_artifacts
attach_workspace:
at: outputs
## Docker image configurations
android_config: &android_config
working_directory: *workspace
docker:
- image: circleci/android:api-28-alpha
environment:
TERM: dumb
_JAVA_OPTIONS: "-Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m"'
## Cache
gradle_key: &gradle_key
jars-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
gems_key: &gems_key
gems-{{ checksum "Gemfile.lock" }}
restore_gradle_cache: &restore_gradle_cache
restore_cache:
key: *gradle_key
restore_gems_cache: &restore_gems_cache
restore_cache:
key: *gems_key
save_gradle_cache: &save_gradle_cache
save_cache:
key: *gradle_key
paths:
- ~/.gradle
- ~/.m2
save_gems_cache: &save_gems_cache
save_cache:
key: *gems_key
paths:
- vendor/bundle
## Dependencies
ruby_dependencies: &ruby_dependencies
run:
name: Download Ruby Dependencies
command: bundle update || bundle install --path vendor/bundle
android_dependencies: &android_dependencies
run:
name: Download Android Dependencies
command: ./gradlew androidDependencies
clean_gradle: &clean_gradle
run:
name: Clean gradle || ./gradlew clean
command: ./gradlew clean
build_apk: &build_apk
run:
name: Build apk || ./gradlew assembleDebug
command: ./gradlew clean assembleDebug --no-daemon --stacktrace
deploy_to_hockey: &deploy_to_hockey
run:
name: Deploy to hockey app
command: sh ./scripts/deployHockeyApp.sh
jobs:
## Run unit tests
test_unit:
<<: *android_config
steps:
- checkout
- run:
name: Current branch
command: echo ${CIRCLE_BRANCH}
- *restore_gradle_cache
- *restore_gems_cache
- *ruby_dependencies
- *android_dependencies
- *save_gradle_cache
- *save_gems_cache
- run:
name: Run unit tests
command: bundle exec fastlane unit_tests
- store_artifacts:
path: app/build/reports/
destination: /reports/
- store_test_results:
path: app/build/test-results/
destination: /test-results/
deploy:
<<: *android_config
steps:
- checkout
- run:
name: Upload to HockeyApp
command: sh ./scripts/deployHockeyApp.sh
deploy_hockeyapp:
docker:
- image: circleci/android:api-28-alpha
environment:
JVM_OPTS: -Xmx4G
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" }}
- *clean_gradle
- *build_apk
- store_artifacts:
path: app/build/outputs/apk/development
destination: apks/
- *deploy_to_hockey
workflows:
version: 2
workflow:
jobs:
- test_unit
- deploy_hockeyapp:
filters:
branches:
only:
- beta
- develop
- /test\/ci_fastfile
- /test\/ci_fastfile2/
- /test\/ci_fastfile2
- deploy_play_store:
filters:
branches:
only:
- production
requires:
- test_unit
它总是在步骤 * build_apk
上失败真的很感谢任何评论/答案,自2天前开始就在进行评论。
答案 0 :(得分:2)
很难说无法访问CircleCI构建机器失败(检查日志等)的原因,但是这里是CiclreCI v2的配置,可构建APK并将其交付给Fabric beta,也类似于将APK交付给Google Play alpha / beta的工作/ prod频道。
我将此构建用作模板,并且无论是否使用proguard,Debug
和Release
的构建都可以在多个项目中使用。
version: 2
jobs:
develop_build:
working_directory: ~/code
docker:
- image: circleci/android:api-27-node8-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Chmod permissions
command: chmod +x gradlew
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- store_artifacts:
path: app/build/reports
destination: reports
- store_test_results:
path: app/build/test-results
- run:
name: Generate fabric config
command: ./gradlew fabricProp
- run:
name: Build prod release app
command: ./gradlew assembleProdRelease -PversionCode=$CIRCLE_BUILD_NUM
- run:
name: Upload DEVELOP PROD to Fabric Beta
command: ./gradlew crashlyticsUploadDistributionProdRelease
- run:
name: Build dev release app
command: ./gradlew assembleDevRelease -PversionCode=$CIRCLE_BUILD_NUM
- run:
name: Upload DEVELOP DEMO to Fabric Beta
command: ./gradlew crashlyticsUploadDistributionDevRelease
workflows:
version: 2
build_app:
jobs:
- develop_build:
filters:
branches:
only: develop