【发布时间】:2018-03-06 12:53:36
【问题描述】:
Gradle 文件和 Android Manifest 如下所示。我尝试了 Stack Overflow 上所有可用的解决方案。
得到这个异常:
com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex
App Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.bharat.photoblog"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
implementation 'de.hdodenhof:circleimageview:2.2.0'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation 'com.android.support:design:26.1.0'
}
apply plugin: 'com.google.gms.google-services'
项目 Gradle
buildscript {
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bharat.photoblog">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat" />
<activity android:name=".LoginActivity" />
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
<activity android:name=".RegisterActivity" />
<activity android:name=".SettingActivity" />
</application>
</manifest>
【问题讨论】:
-
查看 Gradle 控制台输出的其余部分以获取 Java 堆栈跟踪。通常(尽管不是所有时间),那里会有更多关于哪里出了问题的信息。有时,您需要从命令行运行构建并使用
--stacktrace开关来获取完整的堆栈跟踪。 -
请张贴在
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex消息之前打印的完整日志。 -
Unable to merge dex的可能重复
标签: java android android-studio exception compiler-errors