Android java.lang.NoClassDefFoundError:com.parse.parse$Configuration$Builder在下面的棒棒糖版本上

Android java.lang.NoClassDefFoundError:com.parse.parse$Configuration$Builder在下面的棒棒糖版本上,android,parse-platform,noclassdeffounderror,android-multidex,Android,Parse Platform,Noclassdeffounderror,Android Multidex,我正在我的应用程序中使用parse.com sdk与棒棒糖一起使用效果绝对不错。但当我在下面的棒棒糖版本上运行应用程序时,我会出现以下错误: 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

我正在我的应用程序中使用parse.com sdk与棒棒糖一起使用效果绝对不错。但当我在下面的棒棒糖版本上运行应用程序时,我会出现以下错误:

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)
我在初始化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>
}


我如何解决这个问题?

查看您的依赖项,因为您确认已启用多线程,请考虑此(引用官方文档):

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

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

这个方法非常简单,而且很容易理解

你基本上必须:

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

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

  • 跳过必须在清单中将
    多索引应用程序
    设置为
    应用程序
    名称的步骤(因为您有自己的
    应用程序
    类)

由于您有一个自定义的
应用程序
类,因此在设置multidex支持库时请小心:

如果应用程序使用扩展应用程序类,则可以覆盖 方法并调用MultiDex.install(this)以启用 多重索引

因此,请从自定义
应用程序
类调用此方法


请检查是否有新版本的库:如果是这种情况,Android Studio应向您发出警告。

您的应用程序中的min SDK是什么?您是否启用了multidex?是的,我已启用multidex。我应该发布完整的应用程序等级代码吗?是的,请。谢谢。添加了完整的gradle文件代码。太好了!快乐编码;)
  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'

}