gpt4 book ai didi

android - 迁移到 Gradle 插件 3.0 后编译时出现 DexArchiveBuilderException

转载 作者:行者123 更新时间:2023-12-03 04:48:20 24 4
gpt4 key购买 nike

我最近从 2.3.3 升级了我们的 android 应用程序的 gradle 插件。至3.0.0 .在解决了大部分编译问题后,我仍然受到以下异常的困扰:

com.android.build.api.transform.TransformException: 
com.android.builder.dexing.DexArchiveBuilderException:
com.android.builder.dexing.DexArchiveBuilderException:
Failed to process /Users/{user}/SourceCode/Android/{project_path}/build/intermediates/transforms/profilers-transform/debug/113.jar
{user}{project_path}字段是实际值的占位符。

我不完全确定到底发生了什么,但从堆栈跟踪的外观来看,构建未能对我们的第三方 sdk 之一( Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing com/outbrain/OBSDK/HttpClient/OBHttpClient.class )进行 dex 处理。奇怪的是,如果我在内部构建项目,或者如果我构建并生成用于调试和发布的 apk,构建会按预期工作。只有当我尝试在模拟器上部署应用程序时才会收到此错误。

任何有关此错误发生原因的见解将不胜感激。

注意:我引用了 Google Doc ( https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html),我没有看到任何关于这个问题的信息。

这是相关堆栈跟踪的输出:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /Users/{user}/SourceCode/Android/{project_path}/build/intermediates/transforms/profilers-transform/debug/113.jar
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.launchProcessing(DexArchiveBuilderTransform.java:550)
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.lambda$convertToDexArchive$1(DexArchiveBuilderTransform.java:488)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing com/outbrain/OBSDK/HttpClient/OBHttpClient.class

at com.android.builder.dexing.DxDexArchiveBuilder.getExceptionToRethrow(DxDexArchiveBuilder.java:143)
at com.android.builder.dexing.DxDexArchiveBuilder.convert(DxDexArchiveBuilder.java:89)
at com.android.build.gradle.internal.transforms.DexArchiveBuilderTransform.launchProcessing(DexArchiveBuilderTransform.java:545)
... 6 more

Caused by: com.android.dx.cf.code.SimException: stack: underflow
at com.android.dx.cf.code.ExecutionStack.throwSimException(ExecutionStack.java:341)
at com.android.dx.cf.code.ExecutionStack.peek(ExecutionStack.java:206)
at com.android.dx.cf.code.ExecutionStack.peekType(ExecutionStack.java:241)
at com.android.dx.cf.code.Simulator$SimVisitor.visitNoArgs(Simulator.java:427)
at com.android.dx.cf.code.BytecodeArray.parseInstruction(BytecodeArray.java:584)
at com.android.dx.cf.code.Simulator.simulate(Simulator.java:103)
at com.android.dx.cf.code.Ropper.processBlock(Ropper.java:790)
at com.android.dx.cf.code.Ropper.doit(Ropper.java:745)
at com.android.dx.cf.code.Ropper.convert(Ropper.java:350)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:309)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:150)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:102)
at com.android.builder.dexing.DxDexArchiveBuilder.dex(DxDexArchiveBuilder.java:107)
at com.android.builder.dexing.DxDexArchiveBuilder.convert(DxDexArchiveBuilder.java:86)
... 7 more

编辑:将项目 build.gradle 添加到问题中。注意:为敏感信息添加了占位符:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
allprojects {
repositories {
jcenter()
maven {
url 'http://dl.bintray.com/optimizely/optimizely'
}
}
}

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'

// The Fabric Gradle plugin uses an open ended version to
// react quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'

classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'

// Kotlin Support
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.51'
}
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.jakewharton.hugo'
apply plugin: 'kotlin-android'

repositories {
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
maven {
url "http://appboy.github.io/appboy-android-sdk/sdk"
}
maven {
url "http://dl.bintray.com/teads/TeadsSDK-android"
}
maven {
url "https://jitpack.io"
}
flatDir {
dirs 'libs'
}
google()
}

// Test Dependencies
dependencies {
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.robolectric:robolectric:3.0'
testCompile 'org.robolectric:shadows-multidex:3.0'
testCompile 'org.robolectric:shadows-play-services:3.0'
testCompile 'org.easytesting:fest-assert-core:2.0M10'
// testCompile 'org.easytesting:fest-assert:1.4'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
testCompile 'org.powermock:powermock-module-junit4-rule:1.6.4'
testCompile 'org.powermock:powermock-api-mockito:1.6.4'
testCompile 'org.powermock:powermock-classloading-xstream:1.6.4'
}

dependencies {

def appCompatVersion = "25.3.1"
def playServicesVersion = "11.0.4"

compile project(':BRShared')
compile project(':CastCompanionLibrary-android')
wearApp project(':wear')

compile fileTree(dir: 'libs', include: '*.jar')

compile(name: 'sharethrough-android-sdk-v4.4.0', ext: 'aar')
compile('com.optimizely:optimizely:+@aar') {
transitive = true
}

compile 'com.android.volley:volley:1.0.0'
compile "com.google.android.gms:play-services:$playServicesVersion"

compile "com.android.support:support-v4:$appCompatVersion"
compile "com.android.support:appcompat-v7:$appCompatVersion"
compile "com.android.support:design:$appCompatVersion"
compile "com.android.support:cardview-v7:$appCompatVersion"
compile "com.android.support:recyclerview-v7:$appCompatVersion"
compile "com.android.support:customtabs:$appCompatVersion"
compile 'com.android.support:support-v4:19.1.0'
compile 'com.android.support:multidex:1.0.1'

compile('com.twitter.sdk.android:tweet-ui:2.3.1@aar') {
transitive = true;
}
compile('com.twitter.sdk.android:twitter-core:2.3.0@aar') {
transitive = true;
}

compile 'com.squareup.okhttp3:okhttp:3.4.2'
compile 'com.squareup.picasso:picasso:2.5.2'

compile 'com.appboy:android-sdk-ui:1.19.0'

// Facebook
compile 'com.facebook.stetho:stetho:1.3.0'
compile 'com.facebook.android:audience-network-sdk:4.26.0'
compile 'com.facebook.android:facebook-android-sdk:4.27.0'

// Inneractive SDK
compile(name: 'ia-mraid-kit-release-7.0.5', ext: 'aar')
compile(name: 'ia-native-kit-release-7.0.5', ext: 'aar')
compile(name: 'ia-sdk-core-full-release-7.0.5', ext: 'aar')
compile(name: 'ia-video-kit-release-7.0.5', ext: 'aar')


compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.2@aar') {
transitive = true;
}

compile 'com.jakewharton:butterknife:7.0.1'

compile 'com.google.code.gson:gson:2.2.4'
compile 'com.outbrain.obsdk:obsdk:2.1.1'
compile 'org.jetbrains.kotlin:kotlin-stdlib:1.1.3'
compile files('libs/bluekai.jar')

// Reactive
compile 'io.reactivex:rxjava:1.3.0'
compile 'io.reactivex:rxandroid:1.2.1'

// ExoPlayer
compile 'com.google.android.exoplayer:exoplayer:r2.4.0'

// AdobePass
compile files('libs/novacorps-adobepass-client-1.1.0.jar')
compile files('libs/nebula-config-1.3.0.jar')

// Needed in libs directory to avoid missing MVPD model compile error
compile files('libs/android_accessenabler-1.9.1.jar')

// Android Spin Kit UI
compile 'com.github.ybq:Android-SpinKit:1.1.0'

// Teads SDK
compile ('tv.teads.sdk:androidsdk:2.4.14:fullRelease@aar') {
transitive = true;
}

// Material Ripple Layout
compile 'com.balysv:material-ripple:1.0.2'

compile 'org.aspectj:aspectjrt:1.8.1'

// Moshi - JSON Object Mapping
compile 'com.squareup.moshi:moshi:1.5.0'

// GIF Image Library - For Animations
compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.8'
}

android {
compileSdkVersion project.compile_sdk_version.toInteger()
buildToolsVersion project.build_tools_version
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId {application_id}
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
versionCode 31500100
versionName {version_name}
ndk {
abiFilters "armeabi-v7a", "x86"
}
minSdkVersion 19

javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
signingConfigs {
release {
keyAlias {key_alias}
keyPassword {key_password}
storeFile file({file_name})
storePassword {store_password}
}
}

buildTypes {
debug {
minifyEnabled false
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
debuggable true

buildConfigField "boolean", "DEBUG_FORCE_UNICORN_OFF", "false"
buildConfigField "boolean", "DEBUG_STETHO", "true"

// These are the values for the authorities and account types.
resValue "string", "account_type", "{application_id}.debug.accounttype"
resValue "string", "authority", "{application_id}.debug"

resValue "string", "about_version_build", defaultConfig.versionName
resValue "string", "about_version_suffix", "debug"
resValue "string", "outbrain_test_mode", "true"
resValue "bool", "enable_view_server", "true"
resValue "bool", "hockey_app_auto_upload", "false"

resValue "string", "base_feed_url", {base_feed_url}
resValue "string", "path_config", "xmldata/configuration-androidtest"

resValue "string", "google_now_check_credentials_url", "{google_check_credentials_url}"
resValue "string", "google_now_add_credentials_url", "{google_add_credentials_url}"
resValue "string", "google_now_add_activity_url", "{google_add_activity_url}"

resValue "string", "com_appboy_push_gcm_sender_id", "{sender_id}"
resValue "string", "com_appboy_api_key", "{api_key}"
}
release {
ext.enableCrashlytics = true
minifyEnabled false
debuggable false
signingConfig signingConfigs.release

buildConfigField "boolean", "DEBUG_FORCE_UNICORN_OFF", "false"
buildConfigField "boolean", "DEBUG_STETHO", "false"

// Reference them again so they get overwritten by the flavor.
resValue "string", "account_type", "{application_id}.accounttype"
resValue "string", "authority", "{application_id}"

resValue "string", "about_version_build", defaultConfig.versionName
resValue "string", "about_version_suffix", "release"
resValue "string", "outbrain_test_mode", "false"
resValue "bool", "enable_view_server", "false"
resValue "bool", "hockey_app_auto_upload", "true"

resValue "string", "base_feed_url", "{base_feed_url}"
resValue "string", "path_config", "xmldata/configuration-androidv4"
resValue "string", "google_now_check_credentials_url", "{google_check_credentials_url}"
resValue "string", "google_now_add_credentials_url", "{google_add_credentials_url}"
resValue "string", "google_now_add_activity_url", "{google_add_activity_url}"

resValue "string", "com_appboy_push_gcm_sender_id", "{sender_id}"
resValue "string", "com_appboy_api_key", "{api_key}"
}
livesim {
ext.enableCrashlytics = true
versionNameSuffix '-LIVE-SIM'
minifyEnabled false
debuggable false
signingConfig signingConfigs.release

buildConfigField "boolean", "DEBUG_FORCE_UNICORN_OFF", "false"
buildConfigField "boolean", "DEBUG_STETHO", "false"

// Reference them again so they get overwritten by the flavor.
resValue "string", "account_type", "{application_id}.accounttype"
resValue "string", "authority", "{application_id}"

resValue "string", "about_version_build", defaultConfig.versionName
resValue "string", "about_version_suffix", "release"
resValue "string", "outbrain_test_mode", "false"
resValue "bool", "enable_view_server", "false"
resValue "bool", "hockey_app_auto_upload", "true"

resValue "string", "base_feed_url", "{base_feed_url}"
resValue "string", "path_config", "xmldata/configuration-androidv4"
resValue "string", "google_now_check_credentials_url", "{google_check_credentials_url}"
resValue "string", "google_now_add_credentials_url", "{google_add_credentials_url}"
resValue "string", "google_now_add_activity_url", "{google_add_activity_url}"

resValue "string", "com_appboy_push_gcm_sender_id", "{sender_id}"
resValue "string", "com_appboy_api_key", "{api_key}"

// Fallback for sub projects
matchingFallbacks = ['release']
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/main']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}

instrumentTest.setRoot('tests')

debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
livesim.setRoot('build-types/livesim')
}
dexOptions {
jumboMode true
preDexLibraries = false
javaMaxHeapSize "6g"
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
testOptions {
unitTests.returnDefaultValues = true
}
}

android.applicationVariants.all { variant ->
variant.outputs.all { output ->
def buildType = variant.variantData.variantConfiguration.buildType.name
outputFileName = "{Application_Name}-" + (buildType == "release" || buildType == "livesim" ? "release-" : "") + "${variant.versionName}.apk"
}
}

dependencies {
compile 'com.android.support.constraint:constraint-layout:+'
}

最佳答案

我已经找到了我的问题的答案,但如果有人仍在寻找答案,我将在此处发布我的解决方案:

事实证明,问题是在启用了 Advanced Profiling 字段的模拟器/物理设备上安装调试版本。这是在 Android Studio 3.0 中启用的一项功能,它允许开发人员从 Android Profiler 的输出中获取更精确和详细的信息。

要求的描述有点误导恕我直言。它表明它需要 API 版本 小于 版本。 26 但事实并非如此(至少对我来说不是)。似乎只能在 API 版本上成功构建 大于 版本。 26 如果您选择启用它。它可能与更新的 Multi-Dex 支持库有关,在 Advanced Profiler 需要它们时,它还没有清除所有方法,但似乎没有关于发生了什么的任何细节。

如果您在低于版本的设备上运行构建。 26(即 Android O),尝试禁用运行配置中的字段(它位于 Edit Run Configurations 窗口中的 Profiling 选项卡下)。

Advanced Profiling Field in Run Configurations

希望有帮助!

关于android - 迁移到 Gradle 插件 3.0 后编译时出现 DexArchiveBuilderException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47063890/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com