android – Gradle assembleDebug和preDexDebug因CircleCI而失败

前端之家收集整理的这篇文章主要介绍了android – Gradle assembleDebug和preDexDebug因CircleCI而失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试使用CircleCI汇编调试器,但它必须无法构建(preDex).
为什么我不能这样做?

>使用ProductFlavor(名称为生产)
> Android Gradle ver.1.1.0-rc1

问题

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

circle.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相关文章