android - Circle CI 2.0 Android assembleDebug始终失败

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

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

Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)



这是我的 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天前开始进行处理。

最佳答案

很难说无法访问CircleCI生成机的失败原因(检查日志等),但这是CiclreCI v2的配置,可生成APK并将其交付给Fabric beta,也类似于将APK交付给Google Play alpha / beta / prod channel 的工作。

我将此构建用作模板,并且无论是否使用proguard,它都可用于DebugRelease构建的多个项目。

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

关于android - Circle CI 2.0 Android assembleDebug始终失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51839287/

相关文章:

android - 在 Google map fragment 中重新定位 MyLocation 按钮

android - 如何在 Appcompat 22 中从汉堡包图标动态更改为向上图标

android - 您如何将本地Maven m2作为属性传递给Gradle?

android - Android Studio Gradle sync说无法下载gradle-3.1.3.pom

AndroidStudio 梯度同步 : failed to resolve

android - 错误:(31,0)未找到Gradle DSL方法: 'targetSdkVersion()'

安卓低功耗蓝牙 : Not hearing advertisements on some devices

java - picasso 和 ImageLoader android

android - 从编译依赖项中排除 .class 文件

Android Studio - 任务 packageAllDebugClassesForMultiDex 重复条目执行失败