NoClassDefFoundError: com.parse.ParseRequest. Android Parse Exception

I created one parse.com application using the parse.com jar. There were 22 versions of the SDK in this Buid project (it worked fine). But after changing from 23, I ran into some problems compiling the application. I tried to clear the project, invalid cache. Rebuild the project, etc., but I ran into the same problem:

 FATAL EXCEPTION: main java.lang.NoClassDefFoundError: com.parse.ParseRequest at com.parse.Parse.initialize(Parse.java:184) 
I can not find the exact solution. I checked the libs jar folder. I also tried with the latest gradle code, but ran into the same error. After removing the syntax banner, I can compile my project. My addictions
  dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') compile files('libs/org.apache.http.legacy.jar') compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.android.support:cardview-v7:23.1.1' compile 'com.google.android.gms:play-services:8.1.0' compile 'de.hdodenhof:circleimageview:1.3.0' compile project(':MaterialShowcaseView') compile files('libs/Parse-1.9.2.jar') compile files('libs/bolts-android-1.2.0.jar') compile files('libs/universal-image-loader-1.9.4.jar') } 

If I change these dependencies with

 compile 'com.parse.bolts:bolts-android:1.4.0' compile 'com.parse:parse-android:1.12.0' 
then the error is different. Mistake:
 java.lang.NoClassDefFoundError: com.parse.ParsePlugins$1 at com.parse.ParsePlugins.restClient(ParsePlugins.java:92) at com.parse.Parse.initializeParseHttpClientsWithParseNetworkInterceptors(Parse.java:762) at com.parse.Parse.initialize(Parse.java:365) at com.parse.Parse.initialize(Parse.java:344) 
Please suggest me what is wrong with this addiction. thanks in advance
+2
android android-gradle
source share
1 answer

The problem is not due to the parse class. By mistake, you get this error due to mulitdex not being processed and parsing initialization at application startup is why it will give the class an undetected error.

add below lines to build.gradle to handle multiple dex

To solve the problem 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. } 

The whole 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. } 

Using the MultiDexApplication API for Android Developers and Developers

To install MultiDex.install , I link to the Android developer link

 public class MyAppClass extends MultiDexApplication{ @Override protected void attachBaseContext(Context newBase) { MultiDex.install(newBase); super.attachBaseContext(newBase); } } 

Sentence

selectively compile the API into your executable

Do not use the entire google service to use only the required library. Since version 6.5, you can selectively compile Google Play APIs into your application. For example, to enable only the Google Fit and Android Wear APIs, replace the following line in the build.gradle file:

 compile 'com.google.android.gms:play-services:8.4.0' 

with these lines:

 compile 'com.google.android.gms:play-services-fitness:8.4.0' compile 'com.google.android.gms:play-services-wearable:8.4.0' 

Let me know if anything.

+3
source share