2

我正在尝试在 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 gradle 文件,所以我的应用程序 gradle 文件如下所示:

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'
}

我正在尝试解决此错误一段时间,所以如果有人可以提供帮助,那将是很大的帮助。提前致谢!

4

2 回答 2

0

尝试减少您正在使用的库的数量,或者在您的应用程序中使用 multidex。我希望您已达到 65k 方法计数限制。

于 2016-04-16T09:58:11.400 回答
0

FingerprintManagerAPI 23及更高版本支持。您的应用程序的最低 SDK 支持为 15。
如果您的应用程序在 Android 版本低于 Marshmellow 的设备上运行,那么您需要使用,FingerprintManagerCompat否则您将遇到上述异常。

https://github.com/hiteshsahu/FingerPrint-Authentication-With-React-Native-Android/blob/master/android/app/src/main/java/com/aproject/modules/BiometricModule.java

于 2017-07-19T06:34:01.203 回答