我尝试使用 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/