1

我在我的应用程序中使用了Cordova 指纹验证插件,但应用程序崩溃并在 logcat 中显示以下错误。

11-14 11:12:47.671:W/PluginManager(30565):线程警告:exec() 调用 FingerprintAuth.authenticate 阻塞了主线程 33 毫秒。插件应该使用 CordovaInterface.getThreadPool()。

11-14 11:12:47.712: D/FingerprintAuthDialog(30565): disableBackup: false 11-14 11:12:47.713: W/ResourceType(30565): 获取资源号 0x00000000 的值时没有包标识符 11-14 11: 12:47.713: D/AndroidRuntime(30565): 关闭 VM 11-14 11:12:47.716: E/AndroidRuntime(30565): 致命异常: main 11-14 11:12:47.716: E/AndroidRuntime(30565):进程:com.fingerPrint,PID:30565 11-14 11:12:47.716:E/AndroidRuntime(30565):android.content.res.Resources$NotFoundException:资源 ID #0x0 11-14 11:12:47.716:E/ AndroidRuntime(30565): 在 android.content.res.Resources.getValue(Resources.java:1351) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android.content.res.Resources.loadXmlResourceParser(Resources .java:2777) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android.content.res.Resources。getLayout(Resources.java:1165) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android.view.LayoutInflater.inflate(LayoutInflater.java:421) 11-14 11:12:47.716: E/ AndroidRuntime(30565): 在 com.fingerPrint.FingerprintAuthenticationDialogFragment.onCreateView(FingerprintAuthenticationDialogFragment.java:87) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android.app.Fragment.performCreateView(Fragment.java:2220 ) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android .app.FragmentManagerImpl.moveToState(FragmentManager.java:1148) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android.app.BackStackRecord.run(BackStackRecord.java:793) 11-14 11:12 :47.716:E/AndroidRuntime(30565):在 android.app。FragmentManagerImpl.execPendingActions(FragmentManager.java:1537) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android.app.FragmentManagerImpl$1.run(FragmentManager.java:482) 11-14 11:12:47.716 : E/AndroidRuntime(30565): 在 android.os.Handler.handleCallback(Handler.java:746) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android.os.Handler.dispatchMessage(Handler. java:95) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 android.os.Looper.loop(Looper.java:148) 11-14 11:12:47.716: E/AndroidRuntime(30565) : 在 android.app.ActivityThread.main(ActivityThread.java:5443) 11-14 11:12:47.716: E/AndroidRuntime(30565): 在 java.lang.reflect.Method.invoke(Native Method) 11-14 11 :12:47.716: E/AndroidRuntime(30565): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 11-14 11:12:47.716:E/AndroidRuntime(30565): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): Logger$UncaughtExceptionHandler.uncaughtException in Logger.java:471 :: Uncaught Exception 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): android.content.res.Resources$NotFoundException: Resource ID #0x0 11-14 11:12:47.718:E/com.worklight.common.Logger$UncaughtExceptionHandler(30565):在 android.content.res.Resources.getValue(Resources.java:1351) 11-14 11:12 :47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 android.content.res.Resources.loadXmlResourceParser(Resources.java:2777) 11-14 11:12:47.718: E/com.worklight。 common.Logger$UncaughtExceptionHandler(30565):在安卓。content.res.Resources.getLayout(Resources.java:1165) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 android.view.LayoutInflater.inflate(LayoutInflater.java :421) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 com.fingerPrint.FingerprintAuthenticationDialogFragment.onCreateView(FingerprintAuthenticationDialogFragment.java:87) 11-14 11:12:47.718 : E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): at android.app.Fragment.performCreateView(Fragment.java:2220) 11-14 11:12:47.718: E/com.worklight.common.Logger$ UncaughtExceptionHandler(30565): 在 android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 android.app。FragmentManagerImpl.moveToState(FragmentManager.java:1148) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 android.app.BackStackRecord.run(BackStackRecord.java:793) 11 -14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1537) 11-14 11:12:47.718: E/com .worklight.common.Logger$UncaughtExceptionHandler(30565): 在 android.app.FragmentManagerImpl$1.run(FragmentManager.java:482) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565 ): 在 android.os.Handler.handleCallback(Handler.java:746) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 android.os.Handler.dispatchMessage(处理程序.java:95) 11-14 11:12:47.718:E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 android.os.Looper.loop(Looper.java:148) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler (30565): 在 android.app.ActivityThread.main(ActivityThread.java:5443) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 java.lang.reflect。 Method.invoke(Native Method) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java: 728) 11-14 11:12:47.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(30565): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 11-14 11: 12:47.723:D/com.worklight.wlclient.api.WLLifecycleHelper(30565):WLLifecycleHelper。WLLifecycleHelper.java:109 中的 logAppSession :: 试图记录没有起始时间戳的应用程序崩溃

遵循的步骤:

  1. 将插件FingerprintAuth.javaFingerprintAuthenticationDialogFragment‌​.javaFingerprintUiHelper.java文件添加到android/src/com/文件夹中
  2. 添加到config.xml

    <feature name="FingerprintAuth">
        <param name="android-package"  value="com.fingerPrint.FingerprintAuth"/>
    </feature> 
    
  3. common/js文件夹中添加了FingerprintAuth.js

  4. 每次部署到设备之前,在cordova_plugins.js中添加以下内容

    { "id": "FingerprintAuth", "file": "../js/FingerprintAuth.js", "clobbers": [ "FingerprintAuth" ] } 
    

5.在main.js文件中添加以下代码检查指纹认证

FingerprintAuth.isAvailable(function(result) {
        if (result.isAvailable) {
              var client_id = "Your client ID";
              var client_secret = "A very secret client secret (once per device)";
                if(result.hasEnrolledFingerprints){
                        FingerprintAuth.show({
                                clientId: client_id,
                                clientSecret: client_secret
                        }, function (result) {
                                if (result.withFingerprint) {


                                            alert("Authentication Success");


                                             //$location.path("singin");

                                } else if (result.withPassword) {
                                        alert("Authenticated with backup password");
                                }
                        }, function(error) {
                                console.log(error); // "Fingerprint authentication not available"
                        });
                }else{
                        alert("Fingerprint auth available, but no fingerprint registered on the device");
                }
        }
}, function(message) {
        alert("Cannot detect fingerprint device : "+ message);
});
4

1 回答 1

0

我不确定这在混合应用程序中是否有效。

但是请注意,根据插件页面,此插件需要 Android API 级别 23,该级别是最近才添加的。请首先确保升级到 MobileFirst Platform Foundation 7.1 的最新 iFix

于 2016-11-14T10:50:10.650 回答