使用cordova-plugin-android-fingerprint-auth

时间:2016-11-14 06:25:01

标签: android cordova ibm-mobilefirst android-fingerprint-api

我在我的应用程序中使用cordova fingerprint auth plugin,但应用程序崩溃并在logcat中显示以下错误。

  

11-14 11:12:47.671:W / PluginManager(30565):线程警告:exec()   调用FingerprintAuth.authenticate阻塞主线程33ms。   插件应该使用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):致命异常:主要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):at   android.content.res.Resources.getValue(Resources.java:1351)11-14   11:12:47.716:E / AndroidRuntime(30565):at   android.content.res.Resources.loadXmlResourceParser(Resources.java:2777)   11-14 11:12:47.716:E / AndroidRuntime(30565):at   android.content.res.Resources.getLayout(Resources.java:1165)11-14   11:12:47.716:E / AndroidRuntime(30565):at   android.view.LayoutInflater.inflate(LayoutInflater.java:421)11-14   11:12:47.716:E / AndroidRuntime(30565):at   com.fingerPrint.FingerprintAuthenticationDialogFragment.onCreateView(FingerprintAuthenticationDialogFragment.java:87)   11-14 11:12:47.716:E / AndroidRuntime(30565):at   android.app.Fragment.performCreateView(Fragment.java:2220)11-14   11:12:47.716:E / AndroidRuntime(30565):at   android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)   11-14 11:12:47.716:E / AndroidRuntime(30565):at   android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)   11-14 11:12:47.716:E / AndroidRuntime(30565):at   android.app.BackStackRecord.run(BackStackRecord.java:793)11-14   11:12:47.716:E / AndroidRuntime(30565):at   android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1537)   11-14 11:12:47.716:E / AndroidRuntime(30565):at   android.app.FragmentManagerImpl $ 1.run(FragmentManager.java:482)11-14   11:12:47.716:E / AndroidRuntime(30565):at   android.os.Handler.handleCallback(Handler.java:746)11-14   11:12:47.716:E / AndroidRuntime(30565):at   android.os.Handler.dispatchMessage(Handler.java:95)11-14   11:12:47.716:E / AndroidRuntime(30565):at   android.os.Looper.loop(Looper.java:148)11-14 11:12:47.716:   E / AndroidRuntime(30565):at   android.app.ActivityThread.main(ActivityThread.java:5443)11-14   11:12:47.716:E / AndroidRuntime(30565):at   java.lang.reflect.Method.invoke(Native Method)11-14 11:12:47.716:   E / AndroidRuntime(30565):at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:728)   11-14 11:12:47.716:E / AndroidRuntime(30565):at   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)11-14   11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler的(30565):   Logger.java:471中的记录器$ UncaughtExceptionHandler.uncaughtException   :: Uncaught Exception 11-14 11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler的(30565):   android.content.res.Resources $ NotFoundException:资源ID#0x0   11-14 11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.content.res.Resources.getValue(Resources.java:1351)11-14   11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.content.res.Resources.loadXmlResourceParser(Resources.java:2777)   11-14 11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.content.res.Resources.getLayout(Resources.java:1165)11-14   11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.view.LayoutInflater.inflate(LayoutInflater.java:421)11-14   11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   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):at   android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)   11-14 11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)   11-14 11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.app.BackStackRecord.run(BackStackRecord.java:793)11-14   11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1537)   11-14 11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.app.FragmentManagerImpl $ 1.run(FragmentManager.java:482)11-14   11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.os.Handler.handleCallback(Handler.java:746)11-14   11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.os.Handler.dispatchMessage(Handler.java:95)11-14   11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.os.Looper.loop(Looper.java:148)11-14 11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   android.app.ActivityThread.main(ActivityThread.java:5443)11-14   11:12:47.718:   E / com.worklight.common.Logger $ UncaughtExceptionHandler(30565):at   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):at   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)11-14   11:12:47.723:D / com.worklight.wlclient.api.WLLifecycleHelper(30565):   WLLifecycleHelper.java中的WLLifecycleHelper.logAppSession:109 ::试过   记录没有开始时间戳的应用程序崩溃

遵循的步骤:

  1. 将插件 FingerprintAuth.java FingerprintAuthenticationDialogFragment .java FingerprintUiHelper.java 文件添加到 android / src / com / < / strong>文件夹
  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. 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);
    });
    

1 个答案:

答案 0 :(得分:0)

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

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