android - Gradle assembleDebug 和 preDexDebug 因 CircleCI 而失败

标签 android gradle circleci

我尝试使用 CircleCI 来assembleDebug,但它肯定无法构建(preDex)。 为什么我不能那样做?

  • 使用 ProductFlavor(名称为 production)
  • Android Gradle ver.1.1.0-rc1

问题

./gradlew assembleProductionDebug died unexpectedly Building 92%3% > :app:preDexProductionDebugaction ./gradlew assembleProductionDebug failed

圆.yml

general:
  artifacts:
    - "app/build/outputs/apk/app-production-release-unaligned.apk"
machine:
  java:
    version: openjdk7
  environment:
    ANDROID_HOME: /usr/local/android-sdk-linux

dependencies:
  pre:
    - echo y | android update sdk --no-ui --all --filter "build-tools-21.1.2"
    - echo y | android update sdk --no-ui --all --filter "platform-tools"
    - echo y | android update sdk --no-ui --all --filter "tools"
    - echo y | android update sdk --no-ui --all --filter "extra-google-google_play_services"
    - echo y | android update sdk --no-ui --all --filter "extra-google-m2repository"
    - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"
    - echo y | android update sdk --no-ui --all --filter "extra-android-support"
    - echo y | android update sdk --no-ui --all --filter "android-21"
    - git submodule sync
    - git submodule update --init
  cache_directories:
    - ~/.android
    - ~/android
  override:
    - ./gradlew dependencies

test:
  override:
    - ./gradlew test

deployment:
  master:
    branch: master
    commands:
      - ./gradlew assembleProductionDebug

最佳答案

我遇到了同样的问题。事实证明,我必须为 ci 构建禁用 preDex。

把它放在 root build.gradle 中:

project.ext.preDexLibs = !project.hasProperty('disablePreDex')

subprojects {
    project.plugins.whenPluginAdded { plugin ->
        if ("com.android.build.gradle.AppPlugin".equals(plugin.class.name)) {
            project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
        } else if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
            project.android.dexOptions.preDexLibraries = rootProject.ext.preDexLibs
        }
    }
}

然后您可以使用以下命令在您的 ci 上构建:

./gradlew ... -PdisablePreDex

关于android - Gradle assembleDebug 和 preDexDebug 因 CircleCI 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28409608/

相关文章:

java - 使用触摸输入移动相机 Cocos2D android

java - 从字符串列表中删除字符串项

android - 获取连接失败 : ETIMEDOUT (Connection timed out) in ftp connect

android - 如何删除不需要的dex文件?

circleci - CicleCI V2.1 中的分支问题

circleci - 更改 CircleCI 上的用户

android - 更改sdk版本时,遇到Theme.Dialog错误

java - Android:从头开始重建现有项目

spring - 使用spring和gradle的java.lang.LinkageError

azure-devops - 运行 azure devops YML 文件时当前不支持 anchor