Hey I have a large android project after adding large number of files I started getting
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define
so I searched for my problem and I found a solution is by adding this property to the Gradle file but after I added the project build successfully
but when I run the project I'm getting NoClassDef error on some of my fragment and activity
this is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "cloudappers.com.rta_ca"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':bounceScroller')
compile project(':SwipeMenu')
compile project(':indicator')
compile files('libs/android-async-http.jar')
compile('com.weiwangcn.betterspinner:library:1.1.0') {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
compile files('libs/org.apache.commons.io.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.daimajia.easing:library:1.0.1@aar'
compile 'com.daimajia.androidanimations:library:1.1.3@aar'
compile 'com.edmodo:cropper:1.0.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.leocardz:aelv:1.1@aar'
compile 'com.google.android.gms:play-services:7.8.0'
compile 'com.google.android.gms:play-services-ads:7.8.0'
compile 'com.google.android.gms:play-services-identity:7.8.0'
compile 'com.google.android.gms:play-services-gcm:7.8.0'
compile 'com.android.support:multidex:1.0.0'
}
it's working on android 5 but not on 4.4 and prior
Any help?
From your gradle Here :
1. compile fileTree(dir: 'libs', include: ['*.jar'])
2. compile files('libs/android-async-http.jar')
3. compile files('libs/org.apache.commons.io.jar')
Now if you used line 1 then no need to add line 2 & 3.
Reason is that 'compile fileTree(dir: 'libs', include: ['*.jar'])'
includes all jar file to gradle that is in libs folder..
So remove line 2 & 3.
Thanks.!!