这种情况经常发生,我不确定原因。真的很想知道背后的原因。
我的应用程序的gradle看起来像这样
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':Q-municate_core')
compile "info.hoang8f:fbutton:${rootProject.FButtonVersion}"
compile "com.google.android.gms:play-services:${rootProject.googlePlayServicesVersion}"
compile "com.soundcloud.android:android-crop:${rootProject.cropperVersion}@aar"
compile group: 'com.squareup.picasso', name: 'picasso', version: "${rootProject.picassoVersion}"
compile "com.google.guava:guava:${rootProject.guavaVersion}"
compile "com.makeramen:roundedimageview-apklib:${rootProject.roundedImageViewVersion}"
compile "se.emilsjolander:stickylistheaders:${rootProject.stickyListHeadersVersion}"
compile ('de.keyboardsurfer.android.widget:crouton:1.8.4@aar'){
exclude group: 'com.google.android', module: 'support-v4'
}
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 ('it.sephiroth.android.library:pagerslidingtabstrip:1.1.1'){
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.android', module: 'support-v7'
}
}
这构建得很好,但是我的应用程序与" java.lang.NoClassDefFoundError: com.mface.mcall.utils.Consts"
崩溃并且它在一个完全不同的类上崩溃。 我甚至没有使用过我所包含的库。只是"编译"应用程序gradle中的语句,应用程序开始崩溃。
例如:
607-5607/mcall.mface.com.mcallandroidstudio E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.mface.mcall.utils.Consts
at com.mface.mcall.utils.ImageUtils.getImageLoaderConfiguration(ImageUtils.java:60)
at com.mface.mcall.App.initImageLoader(App.java:32)
at com.mface.mcall.App.initApplication(App.java:42)
at com.mface.mcall.App.onCreate(App.java:27)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1070)
at com.lbe.security.service.core.client.b.x.callApplicationOnCreate(Unknown Source)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4708)
at android.app.ActivityThread.access$1300(ActivityThread.java:173)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1452)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5469)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:857)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
at dalvik.system.NativeStart.main(Native Method)
如果我删除以下行,一切都很好。我不知道为什么;很高兴知道原因,所以我可以解决它。这种情况经常发生在不同的图书馆,例如鸟舍。
compile ('it.sephiroth.android.library:pagerslidingtabstrip:1.1.1'){
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.android', module: 'support-v7'
}
我也尝试了以下组合
compile 'it.sephiroth.android.library:pagerslidingtabstrip:1.1.1'
compile ('it.sephiroth.android.library:pagerslidingtabstrip:1.1.1'){
exclude group: 'com.google.android', module: 'support-v4'
}
没有gradle错误,但应用程序崩溃。
可能在这里遗漏了什么?
完整的应用程序gradle
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "mcall.mface.com.mcallandroidstudio"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
signingConfig signingConfigs.debug
zipAlignEnabled true
}
dexOptions{
// jumboMode = true
preDexLibraries = false
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
//compile 'com.android.support:appcompat-v7:21.0.3'
compile project(':Q-municate_core')
compile "info.hoang8f:fbutton:${rootProject.FButtonVersion}"
compile "com.google.android.gms:play-services:${rootProject.googlePlayServicesVersion}"
compile "com.soundcloud.android:android-crop:${rootProject.cropperVersion}@aar"
compile "com.nostra13.universalimageloader:universal-image-loader:${rootProject.universalImageLoaderVersion}"
compile group: 'com.squareup.picasso', name: 'picasso', version: "${rootProject.picassoVersion}"
compile "com.google.guava:guava:${rootProject.guavaVersion}"
compile "com.makeramen:roundedimageview-apklib:${rootProject.roundedImageViewVersion}"
compile "se.emilsjolander:stickylistheaders:${rootProject.stickyListHeadersVersion}"
compile ('de.keyboardsurfer.android.widget:crouton:1.8.4@aar'){
exclude group: 'com.google.android', module: 'support-v4'
}
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 ('it.sephiroth.android.library:pagerslidingtabstrip:1.1.1'){
exclude group: 'com.google.android', module: 'support-v4'
exclude group: 'com.google.android', module: 'support-v7'
}
}