我正在尝试在android上使用新的指纹扫描功能。我以谷歌为例:https://github.com/googlesamples/android-FingerprintDialog
但是当我运行我的程序时,我得到了这个错误:
04-12 22:51:06.475 9218-9218/ivote.android.gj.ivote E/AndroidRuntime: FATAL EXCEPTION: main
Process: ivote.android.gj.ivote, PID: 9218
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/hardware/fingerprint/FingerprintManager;
at ivote.android.gj.ivote.ActivityPackage.HomeScreen.fingerScan(HomeScreen.java:233)
at ivote.android.gj.ivote.ActivityPackage.HomeScreen$7.onResponse(HomeScreen.java:188)
at ivote.android.gj.ivote.ActivityPackage.HomeScreen$7.onResponse(HomeScreen.java:176)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5383)
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:939)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:734)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.hardware.fingerprint.FingerprintManager" on path: DexPathList[[zip file "/data/app/ivote.android.gj.ivote-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
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 ivote.android.gj.ivote.ActivityPackage.HomeScreen.fingerScan(HomeScreen.java:233)
at ivote.android.gj.ivote.ActivityPackage.HomeScreen$7.onResponse(HomeScreen.java:188)
at ivote.android.gj.ivote.ActivityPackage.HomeScreen$7.onResponse(HomeScreen.java:176)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:60)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5383)
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:939)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:734)
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
我试图在谷歌上找到这个问题的解决方案,但无济于事。很少有SO问题指出了n渐变文件的错误,所以我的应用程序渐变文件看起来像这样:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "ivote.android.gj.ivote"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile "com.android.support:support-v13:23.1.1"
compile 'com.squareup.picasso:picasso:2.5.2'
compile project(path: ':volley')
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.github.PhilJay:MPAndroidChart:v2.2.3'
compile 'com.journeyapps:zxing-android-embedded:3.0.2@aar'
compile 'com.google.zxing:core:3.2.0'
}
我正在努力解决这个错误一段时间,所以如果有人能帮忙,那将是一个很大的帮助。提前感谢!
尽量减少正在使用的库的数量,或者在应用程序中使用multidex。我希望你已经达到65k方法的计数限制。
FingerprintManager
在API 23及更高版本中受支持。您的应用程序的最低SDK支持为15。
如果你的应用程序运行在比Marshmelow旧的Android版本的设备上,那么你需要使用FingerprintManagerCompat
,否则你会遇到上述异常。
https://github.com/hiteshsahu/FingerPrint-Authentication-With-React-Native-Android/blob/master/android/app/src/main/java/com/aproject/modules/BiometricModule.java