获取java.lang.NoClassDefFoundError的更新到API的23后 [英] Getting java.lang.NoClassDefFoundError after updating to API 23

查看:767
本文介绍了获取java.lang.NoClassDefFoundError的更新到API的23后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个Android应用程序,当我是半路使用SDK经理通过我更新了我的SDK版本,我也更新的Andr​​oid Studio来1.3.2。这样做在某些设备上这是我的应用程序崩溃,但并不是所有的后。

I am building an android app and when I was halfway through I updated my SDK version using SDK manager, I also updated Android Studio to 1.3.2. After doing this my app crashes on certain devices, but not all.

我得到的错误是

Process: com.pickingo.fe, PID: 11543
    java.lang.NoClassDefFoundError: android.support.v4.hardware.fingerprint.FingerprintManagerCompatApi23$1
            at java.lang.Class.classForName(Native Method)
            at java.lang.Class.forName(Class.java:308)
            at com.activeandroid.ReflectionUtils.getModelClasses(ReflectionUtils.java:83)
            at com.activeandroid.DatabaseHelper.onCreate(DatabaseHelper.java:46)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
            at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
            at com.activeandroid.Registry.openDatabase(Registry.java:149)
            at com.activeandroid.Registry.initialize(Registry.java:107)
            at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:8)
            at com.pickingo.fe.Application.onCreate(Application.java:25)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1034)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4605)
            at android.app.ActivityThread.access$1500(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1353)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)

这是我Application.java类

and this is my Application.java class

import android.content.Context;

import com.activeandroid.ActiveAndroid;
import com.pickingo.fe.notification.NotificationManager;
import com.pickingo.fe.preference.PreferenceManager;
import com.pickingo.fe.sync.ServerUpdatePusher;
import com.pickingo.fe.test.StoreLogcat;

public class Application extends android.app.Application {


    public static boolean init = true;

    public static final String PF_INIT = "pf_init";


    @Override
    public void onCreate() {
        super.onCreate();
        new Thread(new StoreLogcat()).start();
        Context context = getApplicationContext();
        ActiveAndroid.initialize(context);
        ServerUpdatePusher.init(context);
        NotificationManager.init(context);
        PreferenceManager.init(context);
        //GPSFetcherSingleton.init(context);


        init = false;
        android.preference.PreferenceManager
                .getDefaultSharedPreferences(context).edit().putBoolean(PF_INIT, false).apply();
    }


}

另外,这是我的build.gradle

Also this is my build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.x.y"
        minSdkVersion 16
        targetSdkVersion 22
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')

    compile project(':lib_MaterialDesign_EditText')
    compile project(':library_Android_Validator')
    compile project(':lib_MaterialDesign')

    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.netflix.rxjava:rxjava-core:0.+'
    compile 'com.netflix.rxjava:rxjava-android:0.+'
    compile 'de.hdodenhof:circleimageview:1.2.1'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.google.android.gms:play-services:7.5.+'

    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.0.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
    compile 'com.android.support:appcompat-v7:22.1.1'

}

任何帮助将是AP preciated。在此先感谢!

Any help would be appreciated. Thanks in advance !!

推荐答案

在使用编译com.android.support:recyclerview-v7:+,你在说什么你总是希望RecyclerView库的最新版本。然后,这在最新修订拉(在这种情况下, 23.0.1 ),使您的应用程序使用RecyclerView的API 23的特定版本和它的依赖 - 即支持-V4:23.0.1 ,这就是你的错误是来自

When using compile 'com.android.support:recyclerview-v7:+', you are saying you always want the latest version of the RecyclerView library. This then pulls in the newest revision (in this case, 23.0.1), causing your app to use the API 23 specific versions of RecyclerView and its dependencies - namely, support-v4:23.0.1, which is where your error is coming from.

您可以改为声明的特定版本级别 RecyclerView 如:

You can instead declare a specific version level of RecyclerView such as:

'com.android.support:recyclerview-v7:22.+'`

如果你想留在API 22内置的依赖,但在许多情况下,使用动态版本号在所有的是一个坏主意 - 而不是考虑使用的API 22版的完全 22.2.1 最新版本

If you want to stay on the API 22 built dependency, although in many cases, using a dynamic version number at all is a bad idea - instead consider using the exactly 22.2.1 latest version of the API 22 version.

这篇关于获取java.lang.NoClassDefFoundError的更新到API的23后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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