NoClassDefFoundError:com.parse.ParseRequest.Android解析异常 [英] NoClassDefFoundError: com.parse.ParseRequest. Android Parse Exception

查看:24
本文介绍了NoClassDefFoundError:com.parse.ParseRequest.Android解析异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 parse.com jar 创建了一个示例应用程序.在这个项目中,Buid 版本 SDK 是 22(运行良好).但是在将其更改为 23 后,我在编译应用程序时遇到了一些问题.我试图清理项目,使缓存无效.重建项目等,但我面临同样的问题错误是:

I have create one sample app using parse.com jar. In this project Buid version SDK was 22(it was running fine). But after change it with 23 I am facing some issues in compiling app. I have tried to clean project, Invalidate caches. Rebuild project etc but I faced same issue error is:

FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.parse.ParseRequest
at com.parse.Parse.initialize(Parse.java:184)

我找不到确切的解决方案.我已经检查过 libs 文件夹中有 jar.我也尝试过使用最新的 gradle 代码,但遇到了同样的错误.删除 parse jar 后,我可以编译我的项目.我的依赖项是

I can't get find exact solution. I have checked libs folder have jar. I have also tried with latest gradle code but faced same error. After removing parse jar I can compile my project. My dependencies are

    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 this dependencies with

compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.12.0'

然后错误是不同的.错误是:

then error is different. Error is:

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 dependency. Thanks in advance

推荐答案

问题不是因为解析类.错误是因为 multidex 未处理&解析的初始化是在应用程序启动时进行的,这就是为什么它会给出找不到类的错误.

Issue is not because of parse class.In error you get that error because of mulitdex not handled & Initilization of parse is on app start up thats why it will give class not found error.

build.gradle中添加以下几行来处理多dex

add below lines to build.gradle to handle multi dex

解决我在 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.

}

借助android开发者multidex指南MultiDexApplication类

要安装 MultiDex.install 我参考 android 开发者链接

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

建议

有选择地将 API 编译到您的可执行文件中

不要使用整个 google play 服务,只使用必需的库.从 6.5 版开始,您可以有选择地将 Google Play 服务 API 编译到您的应用程序中.例如,要仅包含 Google Fit 和 Android Wear API,请替换 build.gradle 文件中的以下行:

Don't use entire google play service use only required library.From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:

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

用这些行:

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

如果有的话请告诉我.

这篇关于NoClassDefFoundError:com.parse.ParseRequest.Android解析异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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