gpt4 book ai didi

调试应用程序时出现 Android Studio dexDebug 错误

转载 作者:太空狗 更新时间:2023-10-29 16:33:19 25 4
gpt4 key购买 nike

昨天,当我尝试调试我的应用程序并在我的设备上运行它时,Gradle 控制台在 :mobile:dexDebug 之后立即开始显示此错误:

AGPBI: {"kind":"SIMPLE","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","position":{},"original":"UNEXPECTED TOP-LEVEL EXCEPTION:"}
AGPBI: {"kind":"SIMPLE","text":"com.android.dex.DexException: Multiple dex files define Lcom/parse/ParseFacebookUtils;","position":{},"original":"com.android.dex.DexException: Multiple dex files define Lcom/parse/ParseFacebookUtils;"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)","position":{},"original":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)","position":{},"original":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)","position":{},"original":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","position":{},"original":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)","position":{},"original":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)","position":{},"original":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:277)","position":{},"original":"\tat com.android.dx.command.dexer.Main.run(Main.java:277)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:245)","position":{},"original":"\tat com.android.dx.command.dexer.Main.main(Main.java:245)"}
AGPBI: {"kind":"SIMPLE","text":"\tat com.android.dx.command.Main.main(Main.java:106)","position":{},"original":"\tat com.android.dx.command.Main.main(Main.java:106)"}


FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':mobile:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_11\bin\java.exe'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

我在这里做了一些研究,它似乎与 build.gradle 文件中的依赖项有关。我的所有 SDK 都是最新的。

build.gradle(模块:移动):

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion '23.0.0'

defaultConfig {
applicationId "com.intap.tof"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

repositories { mavenCentral() }

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
wearApp project(':wear')
compile 'com.parse:parse-android:1.+'
compile fileTree(include: 'achartengine-1.1.0.jar', dir: 'libs')
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.jjoe64:graphview:4.0.1'
}

最佳答案

com.android.dex.DexException: Multiple dex files define Lcom/parse/ParseFacebookUtils;","position":{},"original":"com.android.dex.DexException: Multiple dex files define Lcom/parse/ParseFacebookUtils;"}

首先在你的build.gradle部分添加multidex

  1. 设置 buildToolsVersion '23.0.1'
  2. 设置编译'com.parse.bolts:bolts-android:1.2.1'

  3. 设置编译'com.parse:parse-android:1.11.0'

  4. 更改 Gradle 构建配置以启用 multidex

  5. 清理-重建-同步

修改您的应用 Gradle 构建文件配置以包含支持库并启用 multidex 输出。

    android {
compileSdkVersion 23
buildToolsVersion '23.0.1'

defaultConfig {
...
minSdkVersion 14
targetSdkVersion 23
...

// Enabling multidex support.
multiDexEnabled true
}
...
}

dependencies {
compile 'com.android.support:multidex:1.0.1'
}

详情请阅读 DexException

https://developer.android.com/intl/es/tools/building/multidex.html

关于调试应用程序时出现 Android Studio dexDebug 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34450253/

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