以下Lollipop版本上的java.lang.NoClassDefFoundError:com.parse.Parse $ Configuration $ Builder [英] java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder on below Lollipop versions

查看:95
本文介绍了以下Lollipop版本上的java.lang.NoClassDefFoundError:com.parse.Parse $ Configuration $ Builder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用parse.com sdk. 与Lollipop完美配合.但是,当我在以下棒棒糖版本上运行该应用程序时,出现此错误:

I am using parse.com sdk in my app. It is working absolutely fine with Lollipop. But when I run the app on below lollipop versions I get this error:

java.lang.NoClassDefFoundError: com.parse.Parse$Configuration$Builder
at com.parse.Parse.initialize(Parse.java:297)
at com.xxx.android.MyApp.onCreate(MyApp.java:16)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4747)
at android.app.ActivityThread.access$1500(ActivityThread.java:166)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1343)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5584)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
at dalvik.system.NativeStart.main(Native Method)

初始化解析器时出现此错误

I'm getting this error when initialising parse by

Parse.initialize(this); 

应用程序类代码:

public class MyApp extends Application {
@Override
public void onCreate() {
    super.onCreate();
    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);
    Parse.initialize(this);
}

}

我的清单代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxx.android">


<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<application
    android:name="com.xxx.android.MyApp"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
    <activity
        android:name="com.xxx.android.HomeActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <meta-data
        android:name="com.parse.APPLICATION_ID"
        android:value="@string/app_id" />
    <meta-data
        android:name="com.parse.CLIENT_KEY"
        android:value="@string/client_key" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="@string/api_key" />
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
</application>

等级:

  apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.xxx.android"
    minSdkVersion 9
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
    multiDexEnabled true

}
dexOptions {
    incremental = true;
    preDexLibraries = false
    javaMaxHeapSize "4g" 
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.12.0'
compile 'com.parse:parseui-widget-android:0.0.1'
compile 'com.google.code.gson:gson:2.5'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.marshalchen.ultimaterecyclerview:library:0.3.18'

}

我该如何解决?

推荐答案

查看您的依赖项,并确认已启用Multidex,请考虑以下事项(引用官方文档):

Looking at your dependencies and since you have confirmed you have multidex enabled, please consider this (quoting from the official documentation):

Android 5.0之前版本的平台使用Dalvik运行时 用于执行应用程序代码.默认情况下,Dalvik将应用程序限制为单个 每个APK的classes.dex字节码文件.为了解决这个问题 限制,您可以使用multidex支持库.

Versions of the platform prior to Android 5.0 use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can use the multidex support library.

这意味着您必须设置multidex支持库才能启用multidex,并能够在运行Android 5.0之前版本的设备上运行应用程序.

It means you have to set the multidex support library in order to enable multidex and to be able to run your application on devices running a version of Android prior to 5.0.

官方文档非常简单,而且非常简单跟随.

The official documentation is quite straightforward and it's really simple to follow.

您基本上必须:

    defaultConfig部分中
  • 启用multidex支持,添加:multiDexEnabled true
  • 将库声明为依赖项:

  • enable multidex support in your defaultConfig section adding: multiDexEnabled true
  • declare the library as a dependency:

编译'com.android.support:multidex:1.0.0'

compile 'com.android.support:multidex:1.0.0'

跳过在清单中将MultiDexApplication设置为application名称的步骤(因为您拥有自己的Application类).

skip the step where you have to set MultiDexApplication in the manifest as the application name (because you have your own Application class).

由于您具有自定义的Application类,因此在设置multidex支持库时请多加注意:

Since you have a custom Application class, please be careful while you set the multidex support library:

如果您的应用使用扩展了Application类,则可以覆盖 attachBaseContext()方法并调用MultiDex.install(this)以启用 多dex.

If your app uses extends the Application class, you can override the attachBaseContext() method and call MultiDex.install(this) to enable multidex.

因此,请从您的自定义Application类中调用此方法.

So call this method from your custom Application class.

请检查该库是否有新版本:如果是这种情况,Android Studio会警告您.

Please check if there's a new version of the library: Android Studio should give you a warning if that's the case.

这篇关于以下Lollipop版本上的java.lang.NoClassDefFoundError:com.parse.Parse $ Configuration $ Builder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆