Getting java.lang.NoClassDefFoundError after upgrading to API 23

I am creating an Android application, and when I was halfway through, I updated the SDK version using the SDK manager, I also updated Android Studio to 1.3.2. After that, my application crashes to certain devices, but not all.

The error I get is

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) 

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(); } } 

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.xy" 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 greatly appreciated. Thanks in advance!

+2
source share
2 answers

When using compile 'com.android.support:recyclerview-v7:+' you say you always want the latest version of the RecyclerView library. Then it pulls in the new version (in this case 23.0.1 ), forcing your application to use specific versions of the RecyclerView API 23 and its dependencies, namely support-v4:23.0.1 , from which your error comes from.

Instead, you can declare a specific version level of RecyclerView , for example:

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

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

+7
source

FingerprintManager supported in API 23 and above. The minimum SDK support for your application is 15.

If your application runs on a device with an Android version older than Marshmallow, you need to use FingerprintManagerCompat , otherwise you will run into an exception.

0
source

Source: https://habr.com/ru/post/1233237/


All Articles