0

每次 Circle CI 运行./gradlew assembleDebug部分,它总是失败。我不知道问题出在哪里,但我尝试了很多方法,比如有无运行它daemon或设置gradle.properties. 我一直在谷歌和 SO 上寻找答案,但仍然找不到合适的答案。这是错误

Gradle build daemon 意外消失(可能已被杀死或崩溃)

这是我的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 天前以来一直在努力。

4

1 回答 1

2

很难说如果没有访问您的 CircleCI 构建机器(检查日志等)会失败,但这是构建 APK 并将其交付给 Fabric beta 的 CiclreCI v2 的配置,也类似于将 APK 交付给谷歌播放 alpha/beta/prod 频道的工作.

我将此构建用作模板,它适用于两者的多个项目,Debug并且无论是否Release使用 proguard 构建。

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
于 2018-08-14T10:42:51.373 回答