2

I upgraded android studio to the version 3.0.1. Whenever i try to launch my app the gradle build fails and gives me the following error:

Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

I tried every solution possible mentioned in stack overflow but nothing is helping me out.

-Whenever i clean project no error occurs but when i rebuild the project the error come back again.

-I deleted the .gradle file and build file

-I changed from compile to implementation

-I upgraded from 10.2.1 to 11.4.2 for firebase dependencies but it gives me more error such as UNABLE TO RESOLVE DEPENDENCY

-I enabled dex but again it comes up with more errors.

-I enabled the google play services which has the version 46

I searched everthing possible but i am unable to solve this issue. Please help me out of it as all my work is stuck. Any help is appreciated!

build.gradle(Project)

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com'
        }}
 dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.0.0'
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(Module)

apply plugin: 'com.android.application'
android {
    compileSdkVersion 24
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "studentapp.notefi"
        minSdkVersion 17

        targetSdkVersion 24
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

 implementation 'com.android.support:appcompat-v7:24.1.1'
    implementation 'com.android.support:design:24.1.1'
    implementation 'com.android.support:support-v4:24.1.1'
    implementation 'com.android.support:recyclerview-v7:24.1.1'
    implementation 'com.android.support:cardview-v7:24.1.1'
    implementation 'com.google.firebase:firebase-messaging:10.2.1'
    implementation 'com.google.firebase:firebase-database:10.2.1'
    implementation 'com.google.firebase:firebase-storage:10.2.1'
    implementation 'com.google.firebase:firebase-auth:10.2.1'
    implementation 'com.firebaseui:firebase-ui-database:0.4.0'
    implementation 'com.github.barteksc:android-pdf-viewer:2.7.0'
    implementation 'org.apache.commons:commons-io:1.3.2'
    implementation 'com.google.firebase:firebase-crash:10.2.1'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.6'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.android.volley:volley:1.0.0'
    implementation 'com.squareup.okhttp3:okhttp:3.2.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
digital_pro
  • 183
  • 2
  • 13

1 Answers1

0

Please remove this line:

  task clean(type: Delete) {
delete rootProject.buildDir
}

Rest i checked its working fine, i mean it successfully build.

EDITED:

use this code "com.google.android.gms:play-services:11.4.0" instead of "com.google.gms.google-services". and then clean and rebuild

Ankit Patidar
  • 2,731
  • 1
  • 14
  • 22