java.lang.NoClassDefFoundError的4.1和android的工作室5.1.using multidex工作 [英] java.lang.NoClassDefFoundError in 4.1 and working with 5.1.using multidex in android studio
问题描述
我被困在一个非常愚蠢类型的问题,因为3天,仍然没有运气。
我使用Parse.com进行注册并且登录。我也使用Twitter和Facebook。
我的应用程序类onCreate方法: -
I stuck in a very stupid type of problem since 3 days and still no luck. I am using Parse.com for sign up and sign in. I am also using twitter and facebook. My application class oncreate method:-
public void onCreate() {
super.onCreate();
Parse.initialize(this, AppConstants.PARSE_APP_ID, AppConstants.PARSE_CLIENT_KEY);
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
FacebookSdk.sdkInitialize(getApplicationContext());
}
}
我建立的gradle -
My gradle build :-
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "rsi.com.componentsdemo"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
incremental true
javaMaxHeapSize "2048M"
jumboMode = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}}dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'org.apache.httpcomponents:httpmime:4.3'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.facebook.android:facebook-android-sdk:4.2.0'
compile('org.twitter4j:twitter4j-core:4.0.1') {
exclude group: 'com.google.android', module: 'support-v7'
}
compile project(':lib')
compile files('libs/Parse-1.11.0.jar')
}
我使用的解析1.11.0.jar lib目录中的libs文件夹中。
I am using parse 1.11.0.jar lib in libs folder.
现在的事情是一样的code采用的是Android 5.0.1设备运行,但是在4.1.1版本得到崩溃。
Now the thing is that same code is running in android 5.0.1 device but getting crash in 4.1.1 version.
LogCat中是如下: -
LogCat is as follows:-
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.parse.ParsePlugins$Android
at com.parse.Parse.initialize(Parse.java:191)
at rsi.com.componentsdemo.ComponentsDemoAppClass.onCreate(ComponentsDemoAppClass.java:20)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:999)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4151)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
请帮我理清这个问题。谢谢!
Please help me to sort out this problem. Thanks!!
推荐答案
如果您使用的是增量= TRUE
意味着多个DEX选项启用&安培;事情不工作了较低的设备,如4.1(据我所知它不会低于4.4工作)
因为多个DEX文件
If you are using incremental = true
means multiple dex option is enable & things are not working for lower device like 4.1 (AFAIK it wont work below 4.4)
because of multiple dex file
我面临同样的问题,并与下面的4.4 devices.Issue是不符合 ParsePlugin
。
I face same issue with for below 4.4 devices.Issue is not with ParsePlugin
.
要解决的问题是什么我给我的的build.gradle
To resolve issue what i give in my build.gradle
dexOptions {
incremental true
// here heap size give 4g i got this thing from https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY
javaMaxHeapSize "4g"
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
// your dependencies which you are using.
}
整个的build.gradle
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
configurations {
// all*.exclude group: 'com.android.support', module: 'recyclerview-v7'
}
android {
signingConfigs {
/*
releasebuild {
keyAlias 'hellotest'
keyPassword 'hellotest'
storeFile file('path to keystore')
storePassword 'hellotest'
}
*/
}
compileSdkVersion 'Google Inc.:Google APIs:22'
buildToolsVersion '23.0.0'
/* if you got error regarding duplicate file of META-INF/LICENSE.txt from jar file
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
*/
dexOptions {
jumboMode = true
incremental true
// here heap size give 4g i got this thing from https://groups.google.com/forum/#!topic/adt-dev/P_TLBTyFWVY
javaMaxHeapSize "4g"
}
defaultConfig {
multiDexEnabled true
applicationId "com.myapp.packagenme"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.releasebuild
}
debug {
signingConfig signingConfigs.releasebuild
}
}
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
// your dependencies which you are using.
}
和在应用程序类我已经延长 MultiDexApplication
And in Application class i have extended MultiDexApplication
public class MyAppClass extends MultiDexApplication{
@Override
protected void attachBaseContext(Context newBase) {
MultiDex.install(newBase);
super.attachBaseContext(newBase);
}
}
这篇关于java.lang.NoClassDefFoundError的4.1和android的工作室5.1.using multidex工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!