【问题标题】:Circle CI 2.0 Android assembleDebug always failedCircle CI 2.0 Android assembleDebug 总是失败
【发布时间】:2018-08-14 10:27:57
【问题描述】:

Circle CI 每次运行 ./gradlew assembleDebug 部分时,总是会失败。我不知道问题出在哪里,但我尝试了很多方法,比如在有和没有daemon 或设置gradle.properties 的情况下运行它。我一直在谷歌和 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

上总是失败

非常感谢任何 cmets / 答案,自 2 天前以来一直在努力。

【问题讨论】:

    标签: android gradle android-gradle-plugin circleci circleci-2.0


    【解决方案1】:

    如果没有访问您的 CircleCI 构建机器(检查日志等),很难说什么会失败,但这里是 CiclreCI v2 的配置,它构建 APK 并将其交付给 Fabric beta,也类似于将 APK 交付给 google play alpha/beta /prod 频道。

    我将此构建用作模板,它适用于 DebugRelease 构建的多个项目,无论是否使用 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
    

    【讨论】:

    • 感谢您的回答,正如我所说,我们将不胜感激。将首先测试您的配置,很快就会回复您
    • @Webster 它对我不起作用。除了添加 JVM_OPTS: -Xmx3200m 之外,您还做了什么其他事情?
    • @hannanessay,很久以前,我得先检查一下我的笔记本电脑,稍后再通知你
    猜你喜欢
    • 2019-02-21
    • 1970-01-01
    • 2021-03-26
    • 1970-01-01
    • 1970-01-01
    • 2020-09-20
    • 2016-04-11
    • 2020-11-10
    • 1970-01-01
    相关资源
    最近更新 更多