2

while i build debug app i am getting this issue! Help Please.

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

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

adding "multiDexEnabled true" wont work for me

My Gradle File -

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId 'com.test.thing'

        manifestPlaceholders = [onesignal_app_id               : "test",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]
        minSdkVersion 15
        targetSdkVersion 26


    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    repositories {
        jcenter()
        mavenCentral()  // GPUImage for Android
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/acra-4.5.0.jar')
    compile files('libs/ormlite-android-4.43.jar')
    compile files('libs/ormlite-core-4.43.jar')
    // If you want to use the GPU Filters

    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:cardview-v7:24.2.1'
    compile 'com.google.firebase:firebase-ads:10.0.0'
    compile 'com.google.firebase:firebase-messaging:10.0.0'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'jp.wasabeef:glide-transformations:2.0.1'
    compile 'com.onesignal:OneSignal:[3.5.3,4.0.0)'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

}
apply plugin: 'com.google.gms.google-services'

`
Jack N
  • 85
  • 1
  • 2
  • 6

2 Answers2

1
apply plugin: 'com.android.application'



android {

compileSdkVersion 27
defaultConfig {
    applicationId "com.taggroup.www.myapp"
    minSdkVersion 18
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
dexOptions {
    javaMaxHeapSize "4g"
}
buildTypes {
    release {
        minifyEnabled false
        multiDexEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        multiDexKeepFile file('multidex-config.txt')
    }
      }
  } 
dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.firebase:firebase-ads:11.8.0'
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.android.support:support-v4:27.0.2'
implementation 'com.google.android.gms:play-services-auth:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support:recyclerview-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.github.bumptech.glide:glide:4.2.0'
implementation 'com.android.volley:volley:1.1.0-rc1'
implementation 'com.miguelcatalan:materialsearchview:1.4.0'
implementation 'com.paypal.sdk:paypal-android-sdk:2.15.3'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.joanzapata.iconify:android-iconify-fontawesome:2.1.1'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.google.code.gson:gson:2.8.1'
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.google.firebase:firebase-core:11.8.4'
implementation 'com.github.amigold.fundapter:library:1.0'
implementation 'org.apache.httpcomponents:httpclient:4.3.5'
implementation files('./2checkout-java.jar')
}









apply plugin: 'com.google.gms.google-services'

in may case i do this and its work fine and menifast file

  <application
    android:allowBackup="true"
    android:icon="@drawable/logo_ew"
    android:label="Darzee.co"
    android:roundIcon="@drawable/logo_ew"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"
    tools:replace="android:label,android:icon"
    android:name="myapp">
    <activity android:name=".Starter.Loader">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

and class to add in manifest file

package ...........;

import android.content.Context;
import android.os.Bundle;
import android.support.multidex.MultiDex;
import android.support.multidex.MultiDexApplication;
import android.support.v7.app.AppCompatActivity;

import com.google.firebase.crash.FirebaseCrash;



public class myapp extends MultiDexApplication  {
@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}

}
Sufwan Ansari
  • 131
  • 1
  • 6
0

Multidex should be enabled and if you have to explicitly enable multidex for API <= 21

In Gradle File :- Add like this.

android {
    defaultConfig {
        multiDexEnabled true
    }
}

Depdencies section add this line:-

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

In Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>

Moreover make sure you didnt missed anything from here https://developer.android.com/studio/build/multidex.html

And finally Clean and Build the App

lib4backer
  • 3,337
  • 3
  • 18
  • 16
  • adding this line in Manifest giving red error android:name="android.support.multidex.MultiDexApplication" > – Jack N Feb 03 '18 at 05:47