- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
当我在稳定 channel 中将我的 Android Studio 更新到 3.0 并运行项目时,我开始收到以下错误。
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
我尝试清理和重建项目,但没有成功。任何帮助将不胜感激。
项目级 build.gradle
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用级 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.med.app"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resConfigs "auto"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
//appcompat libraries
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
//butterknife
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//picasso
compile 'com.squareup.picasso:picasso:2.5.2'
//material edittext
compile 'com.rengwuxian.materialedittext:library:2.1.4'
// Retrofit & OkHttp & and OkHttpInterceptor & gson
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.google.code.gson:gson:2.8.2'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
// FirebaseUI for Firebase Auth
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
}
apply plugin: 'com.google.gms.google-services'
我已经尝试了所有给出的答案,但我无法解决这个错误。请帮忙。
最佳答案
向 play-services-auth
添加显式依赖项以及您的 firebase-ui-auth
依赖项:
// FirebaseUI for Firebase Auth
compile 'com.firebaseui:firebase-ui-auth:3.1.0'
compile 'com.google.android.gms:play-services-auth:11.4.2'
这是因为 firebase-ui-auth
对 play-services-auth
有传递依赖,必须与对应版本的 play-services 一起使用-auth
。请看 this explanation .
firebase-ui-auth
|--- com.google.firebase:firebase-auth
|--- com.google.android.gms:play-services-auth
Gradle 构建工具的早期版本不包含传递依赖项,因此现在版本可能与其他 play-services
版本发生冲突。
我的问题得到解释和回答(以防万一有人想知道)
当您升级到 Android Studio 3.0 并将 gradle 构建工具版本更新到 3.0.0 时,编译依赖项的方式现在与早期版本不同。
我最近遇到了同样的问题。我正在使用这些依赖项,这些依赖项在 Gradle 2.3.3 版中运行良好:
implementation 'org.apache.httpcomponents:httpmime:4.3.6'
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
升级到 gradle-build-version 3.0.0 后,我得到了同样的错误。仔细研究一下,我发现 httpmime
的传递依赖与文件 httpclient-android
包含冲突。
说明
让我详细解释一下。早些时候,在使用 gradle-tool-version 2.3.3 时,我使用 httpclient-android
来获取和使用名为 org.apache.http.entity.ContentType.java
的类>扩展 org.apache.httpcomponents:httpmime:4.3.6
的传递依赖表明它有 org.apache.httpcomponents:httpcore:4.3.6
这是同一个包我想用。但是在编译或同步构建时,它不包括 org.apache.http.entity.ContentType.java
所以我需要添加这个包含 ContentType.java
的依赖项:
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
之后一切正常。
我将 gradle-build-version 升级到 3.0.0 后,情况发生了变化。它现在包括所有传递依赖。因此,在使用 gradle-build-tool 版本 3.0.0 编译最新的 Android Studio 时,我的 ContentType.java
被编译了两次。一次来自 org.apache.httpcomponents:httpcore:4.3.6
(这是 httpmime
的隐式传递依赖),再次来自 org.apache.httpcomponents:httpclient -android:4.3.5.1
我之前使用的。
要解决此问题,我必须删除现有的 org.apache.httpcomponents:httpclient-android:4.3.5.1
依赖项,因为 httpmime
本身会获取所需的相关类用于我的应用程序。
我的情况的解决方案:只使用所需的依赖项并删除 httpclient-android
implementation 'org.apache.httpcomponents:httpmime:4.3.6'
请注意,这只是我的情况。您需要深入了解自己的依赖项并相应地应用解决方案。
关于android - 无法合并 Dex - Android Studio 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46949761/
Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files defi
我试图在 avd 中运行我的应用程序,但是当我选择运行 gradle 时出现异常: Error:Error converting bytecode to dex: Cause: com.android
当我提取一个文件 aab 时出现这个错误: Invalid dex file indices, expecting file 'classes٢.dex' but found 'classes2.de
我有一个 ionic 项目。它已成功构建并在我的 android 手机中运行。突然有一天,当我运行命令“ionic cordova run android”时,我得到如下构建错误: Dex: Erro
这个问题在这里已经有了答案: Unable to execute dex: Multiple dex files define (31 个回答) 4年前关闭。 我更新了 android studio
从过去 3 天开始,我遇到了这个错误,并且已经尽了我所能。任何人都可以帮我纠正它。我正在使用 Android 3.0,我的 sdk 和 Google Play 服务已更新,并且我已将 multiDex
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.nnroh.debtmanager, PI
好的,现在我真的被困在这里了。我不知道该做什么,去哪里或任何事情! 我一直在尝试卸载、重新安装 SDK 和 Eclipse 版本,尝试用谷歌搜索出来,但是 nu-uh... 什么都没有!!! 我可以在
怎么了?为什么我有这个问题? Unable to execute dex: Multiple dex files define Lcom/nineoldandroids/animation/Anima
我尝试运行我的 android 应用程序,但出现此错误。 [2014-03-11 11:21:34 - Dex Loader] Unable to execute dex: Multiple dex
我希望指定包中的所有类都驻留在主 dex 文件中。 那里有使用通配符的选项吗? 最佳答案 很遗憾,不支持通配符。 但是,您可以使用 this script 生成 main-dex-list 文件。 .
我目前有一个来自霍尼韦尔的 DEX BLE-1 适配器,用于从自动售货机检索 dex 数据。我有一个 swift 3 iOS 应用程序,它使用 CoreBluetooth 进行扫描并与外围设备配对。该
我正在使用 IntelliJ IDEA 12.1.4,在我的项目中我使用了几个库/项目: ActionBarSherlock ViewPagerIndicator Volley ProgressShe
我在尝试运行我的项目时遇到了这个问题 - com.android.builder.dexing.DexArchiveBuilderException: Failed to process .gradl
我一直在四处寻找,有很多帖子与这个问题有关,但似乎没有确定的解决方案(例如 Error when building apk - "Multiple dex files define Lcom/goog
我正在对 Jan Berkel 的 SBT Android 插件进行一些黑客攻击,我在想是否有一种方法可以将多个 .dex 文件合并到一个 .dex 文件中包含所有这些。 例如,如果我有这个: cla
我在尝试运行我的应用程序时遇到了这些问题,但不知道如何解决... 谁能帮帮我 这是错误: [2014-04-18 18:47:35 - Dex Loader] Unable to execute de
这个问题在这里已经有了答案: Android support multidex library implementation (4 个回答) 4年前关闭。 生成签名的apk时,有这个错误,但构建项目是
我有一个 Android 应用程序,(理论上)它可以变成一个库并放入外部应用程序中。然后外部应用程序可以创建一个包含我的应用程序的选项卡。库应用程序的设置方式与 google-play-service
我正在开发一个 android 应用程序并且 gradle 构建工作正常但是现在当我构建我的 android 项目时,gradle 构建失败并显示以下错误 Error converting bytec
我是一名优秀的程序员,十分优秀!