I know there are many questions on this, but I tried the solutions of most of them and neither of them worked. I have an app in which I have imported a module. When I try to run the app, I am getting Unable to merge dex exception.
build.gradle (app module)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.meditab.imspatient"
minSdkVersion 21
targetSdkVersion 27
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'])
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.constraint:constraint-layout:1.0.2' // Constraint layout
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" // Kotlin
// Support libraries
implementation "com.android.support:appcompat-v7:$appcompat_version"
implementation "com.android.support:support-v4:$appcompat_version"
compile project(path: ':commonutils')
}
build.gradel (imported module)
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion '27.0.2'
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jetbrains:annotations-java5:15.0'
compile 'com.jakewharton:butterknife:8.8.1'
// Support libraries
compile "com.android.support:appcompat-v7:$appcompat_version"
compile "com.android.support:design:$appcompat_version"
// Rx related libraries
compile 'io.reactivex:rxjava:1.1.1'
compile 'io.reactivex:rxandroid:1.1.0'
//compile 'com.netflix.rxjava:rxjava-core:0.+'
// Networking related libraries
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-jackson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.estimote:sdk:0.10.+@aar'
}
build.gradle (project level)
buildscript {
ext.kotlin_version = '1.2.21'
ext.appcompat_version = '27.0.2'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Needed for the common utils module
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried deleting the .gradle folder, cleaning the project and rebuilding it. Nothing works. I also tried using implementation instead of compile in the build.gradle of the imported module. Any help will be appreciated. Thanks in advance.