更新到API 23后获取java.lang.NoClassDefFoundError

时间:2015-09-09 15:54:35

标签: android android-studio android-gradle android-6.0-marshmallow

我正在构建一个Android应用程序,当我中途使用SDK管理器更新我的SDK版本时,我还将Android Studio更新为1.3.2。执行此操作后,我的应用程序在某些设备上崩溃,但不是全部。

我得到的错误是

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类

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

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'

}

任何帮助将不胜感激。在此先感谢!!

1 个答案:

答案 0 :(得分:0)

API 23及更高版本支持

FingerprintManager。您应用的最低SDK支持是15。

如果您的应用程序在Android版本低于Marshmallow的设备上运行,那么您需要使用FingerprintManagerCompat,否则您将遇到上述异常。