NoClassDef 在添加 multiDexEnabled 之后
NoClassDef after after Adding multiDexEnabled
嘿,我有一个大型 android 项目,在添加大量文件后我开始获得
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define
所以我搜索了我的问题,我找到了一个解决方案,就是将这个 属性 添加到 Gradle 文件,但是在我添加项目构建成功之后
但是当我 运行 项目时,我的一些片段出现了 NoClassDef 错误并且 activity
这是我的 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'
}
它在 android 5 上工作,但不在 4.4 和之前的
上工作
有什么帮助吗?
来自您的 gradle 这里:
1. compile fileTree(dir: 'libs', include: ['*.jar'])
2. compile files('libs/android-async-http.jar')
3. compile files('libs/org.apache.commons.io.jar')
现在,如果您使用了第 1 行,则无需添加第 2 行和第 3 行。
原因是 'compile fileTree(dir: 'libs', include: ['*.jar'])'
将所有 jar 文件包含到 libs 文件夹中的 gradle..
所以删除第 2 行和第 3 行。
谢谢.!!
嘿,我有一个大型 android 项目,在添加大量文件后我开始获得
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define
所以我搜索了我的问题,我找到了一个解决方案,就是将这个 属性 添加到 Gradle 文件,但是在我添加项目构建成功之后
但是当我 运行 项目时,我的一些片段出现了 NoClassDef 错误并且 activity
这是我的 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'
}
它在 android 5 上工作,但不在 4.4 和之前的
上工作有什么帮助吗?
来自您的 gradle 这里:
1. compile fileTree(dir: 'libs', include: ['*.jar'])
2. compile files('libs/android-async-http.jar')
3. compile files('libs/org.apache.commons.io.jar')
现在,如果您使用了第 1 行,则无需添加第 2 行和第 3 行。
原因是 'compile fileTree(dir: 'libs', include: ['*.jar'])'
将所有 jar 文件包含到 libs 文件夹中的 gradle..
所以删除第 2 行和第 3 行。
谢谢.!!