0

Gradle files and Android Manifest are given below. I tried every solution available on Stack Overflow.

Getting this exception:

com.android.builder.dexing.DexArchiveMergerException: Unable to merge 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'

Project 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
}

Manifest File

<?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>
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Look at the rest of the Gradle console output for a Java stack trace. Usually (though not all of the time), there will be more information there about what went wrong. Sometimes, you will need to run the build from the command line and use the `--stacktrace` switch to get the full stack trace. – CommonsWare Mar 06 '18 at 12:54
  • please post the complete log which is printed before `com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex` message. – Akram Mar 06 '18 at 12:55
  • Possible duplicate of [Unable to merge dex](https://stackoverflow.com/questions/46267621/unable-to-merge-dex) – MaYur MahAjan Mar 06 '18 at 13:00

2 Answers2

0

Please update from:-

com.google.android.gms:play-services:11.2.2

to

com.google.android.gms:play-services:11.4.0.

then :-

clean and rebuild the project.

piet.t
  • 11,718
  • 21
  • 43
  • 52
Abhinav Gupta
  • 2,225
  • 1
  • 14
  • 30
0

I think that appcompat-v7:26.1.0 is not fully compatible with Firebase 11.8.0 try to update to appcompat-v7:27.0.2.. I faced this problem once and that was the solution

Mohammad
  • 739
  • 7
  • 22