如何在添加android指纹身份验证时解决此错误?

时间:2017-09-14 05:39:51

标签: android

我正在开发一款需要google fingerprint auth才能登录我的应用的应用。我的应用程序需要Android 4.4及更高版本(api级别> 19),但指纹身份验证在api级别23之后添加。是否有可能使我的应用程序支持指纹auth与我提到的api级别19。 在我的gradle中,当我把19崩溃并给出以下错误时,我将minsdk设为19。但是当我改为23时,它很好。

E/AndroidRuntime: FATAL EXCEPTION: main

Process: info.androidhive.fingerprint, PID: 15697

java.lang.NoClassDefFoundError: Failed resolution of: 
Landroid/hardware/fingerprint/FingerprintManager;

at info.androidhive.fingerprint.FingerprintActivity.onCreate(FingerprintActivity.java:45)

at android.app.Activity.performCreate(Activity.java:6010)

at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)

at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413)

at android.app.ActivityThread.access$800(ActivityThread.java:155)

at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)

at android.os.Handler.dispatchMessage(Handler.java:102)

at android.os.Looper.loop(Looper.java:135)

at android.app.ActivityThread.main(ActivityThread.java:5343)

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:905)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)

Caused by: java.lang.ClassNotFoundException: Didn't find class "android.hardware.fingerprint.FingerprintManager" on path: DexPathList[[zip file "/data/app/info.androidhive.fingerprint-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
                                                                              at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                              at info.androidhive.fingerprint.FingerprintActivity.onCreate(FingerprintActivity.java:45) 
                                                                              at android.app.Activity.performCreate(Activity.java:6010) 
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129) 
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292) 
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2413) 
                                                                              at android.app.ActivityThread.access$800(ActivityThread.java:155) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                              at android.os.Looper.loop(Looper.java:135) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5343) 
                                                                              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:905) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) 
                                                                            Suppressed: java.lang.ClassNotFoundException: android.hardware.fingerprint.FingerprintManager
                                                                              at java.lang.Class.classForName(Native Method)
                                                                              at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                              at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                              at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                                    ... 15 more
                                                                           Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

1 个答案:

答案 0 :(得分:0)

我们不能在api小于23的情况下使用FingerpintManager。此FingerpintManager的minSdkVersion为23。

如果您想在API级别低于23的应用中使用FingerpintManager,您可以考虑使用FingerprintManagerCompat,其行为就像没有API水平低于23的指纹传感器一样。

有关详细信息,请查看链接以及示例。

https://developer.android.com/reference/android/support/v4/hardware/fingerprint/FingerprintManagerCompat.html

https://github.com/AMykich/Android-Fingerprint-API