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

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

问题描述

我正在构建一个 android 应用程序,当我进行到一半时,我使用 SDK 管理器更新了我的 SDK 版本,我还将 Android 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'

}

任何帮助将不胜感激.提前致谢!!

Any help would be appreciated. Thanks in advance !!

推荐答案

当使用 compile 'com.android.support:recyclerview-v7:+' 时,你是说你总是想要最新版本RecyclerView 库.然后引入最新的修订版(在本例中为 23.0.1),导致您的应用程序使用 API 23 特定版本的 RecyclerView 及其依赖项 - 即 support-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.

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

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