带有NativeScript的NFC(RFID)插件已弃用的问题

时间:2019-08-02 14:25:20

标签: android nativescript nfc

我将开始在NativeScript Vue上为Android平板电脑编写移动应用程序。我想测试NFC插件,但似乎太旧了。

这是插件的存储库:

https://github.com/EddyVerbruggen/nativescript-nfc

我在我的应用程序中实现了一种方法来检查插件是否有效。但是在NativeScript Sidekick的背景下,我得到的错误很少。

  设备Galaxy Tab Active2的

LOG:'\'NativeScript-Vue具有    “ Vue.config.silent”设置为true,以查看输出日志将其设置为false。    设备Galaxy Tab Active2的日志:“ \”是\``    设备Galaxy Tab Active2的日志:发生未捕获的异常    “主”线程。    调用js方法运行失败    错误:java.lang.SecurityException:需要NFC权限:两个用户都没有    10155或当前进程都没有android.permission.NFC。      android.os.Parcel.readException(Parcel.java:2029)      android.os.Parcel.readException(Parcel.java:1975)      android.nfc.INfcAdapter $ Stub $ Proxy.setForegroundDispatch(INfcAdapter.java:1012)      android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1648)      com.tns.Runtime.callJSMethodNative(本机方法)      com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)      com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)      com.tns.Runtime.callJSMethod(Runtime.java:1109)      com.tns.Runtime.callJSMethod(Runtime.java:1089)      com.tns.Runtime.callJSMethod(Runtime.java:1081)      com.tns.gen.java.lang.Runnable.run(Runnable.java:17)      android.os.Handler.handleCallback(Handler.java:790)      android.os.Handler.dispatchMessage(Handler.java:99)      android.os.Looper.loop(Looper.java:164)      android.app.ActivityThread.main(ActivityThread.java:7000)      java.lang.reflect.Method.invoke(本机方法)      com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:441)      com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

     

StackTrace:    框架:功能:'',文件:'file:///data/data/org.nativescript.preview/files/app/vendor.js',第672行,第31列    框架:功能:'调用',文件:'file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/timer/timer.js',行:19,列:45    框架:功能:``运行'',文件:``file:///data/data/org.nativescript.preview/files/app/tns_modules/tns-core-modules/timer/timer.js'',第23行,列:7    在com.tns.Runtime.callJSMethodNative(本机方法)    在com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)    在com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)    在com.tns.Runtime.callJSMethod(Runtime.java:1109)    在com.tns.Runtime.callJSMethod(Runtime.java:1089)    在com.tns.Runtime.callJSMethod(Runtime.java:1081)    在com.tns.gen.java.lang.Runnable.run(Runnable.java:17)    在android.os.Handler.handleCallback(Handler.java:790)    在android.os.Handler.dispatchMessage(Handler.java:99)    在android.os.Looper.loop(Looper.java:164)    在android.app.ActivityThread.main(ActivityThread.java:7000)    在java.lang.reflect.Method.invoke(本机方法)    在com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:441)    在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)   由以下原因引起:java.lang.SecurityException:需要NFC权限:用户10155或当前进程都没有android.permission.NFC。    在android.os.Parcel.readException(Parcel.java:2029)    在android.os.Parcel.readException(Parcel.java:1975)    在android.nfc.INfcAdapter $ Stub $ Proxy.setForegroundDispatch(INfcAdapter.java:1012)    在android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1648)    ...另外14个   设备Galaxy Tab Active2的日志:'\'NativeScript-Vue将“ Vue.config.silent”设置为true,以查看输出日志将其设置为false。   设备Galaxy Tab Active2的日志:'\'OnTagDiscovered侦听器已添加\'   设备Galaxy Tab Active2的日志:“主”线程上发生未捕获的异常。   调用js方法运行失败   错误:java.lang.SecurityException:需要NFC权限:用户10155或当前进程都没有android.permission.NFC。      android.os.Parcel.readException(Parcel.java:2029)      android.os.Parcel.readException(Parcel.java:1975)      android.nfc.INfcAdapter $ Stub $ Proxy.setForegroundDispatch(INfcAdapter.java:1012)      android.nfc.NfcAdapter.enableForegroundDispatch(NfcAdapter.java:1648)      com.tns.Runtime.callJSMethodNative(本机方法)      com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)      com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)      com.tns.Runtime.callJSMethod(Runtime.java:1109)      com.tns.Runtime.callJSMethod(Runtime.java:1089)      com.tns.Runtime.callJSMethod(Runtime.java:1081)      com.tns.gen.java.lang.Runnable.run(Runnable.java:17)      android.os.Handler.handleCallback(Handler.java:790)      android.os.Handler.dispatchMessage(Handler.java:99)      android.os.Looper.loop(Looper.java:164)      android.app.ActivityThread.main(ActivityThread.java:7000)      java.lang.reflect.Method.invoke(本机方法)      com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:441)      com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

此代码可在我的平板电脑上使用,就像我在上面提到的已实现方法中一样。

nfc.available().then(
  function(avail) {
    console.log(avail ? "Yes" : "No");
  }

我在控制台中收到消息“是”。

[19-08-02 15:27:52.337] (CLI) (node:18276) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'hash' of null
    at PreviewAppController.<anonymous> (C:\Users\XXXXXXXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:130:64)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\XXXXXXXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:10:58)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
    at emitWarning (internal/process/promises.js:99:15)
    at processPromiseRejections (internal/process/promises.js:140:9)
    at processTicksAndRejections (internal/process/next_tick.js:82:32)
[19-08-02 15:27:52.340] (CLI) (node:18276) TypeError: Cannot read property 'hash' of null
    at PreviewAppController.<anonymous> (C:\Users\XXXXXXXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:130:64)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\XXXXXXXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:10:58)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
(node:18276) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    at emitDeprecationWarning (internal/process/promises.js:113:13)
    at emitWarning (internal/process/promises.js:106:3)
    at processPromiseRejections (internal/process/promises.js:140:9)
    at processTicksAndRejections (internal/process/next_tick.js:82:32)
[19-08-02 15:32:26.783] (CLI) (node:18276) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'hash' of null
    at PreviewAppController.<anonymous> (C:\Users\XXXXXXXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:130:64)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\XXXXXXXXXXXXX\AppData\Roaming\npm\node_modules\nativescript\lib\controllers\preview-app-controller.js:10:58)
    at processTicksAndRejections (internal/process/next_tick.js:81:5)
    at emitWarning (internal/process/promises.js:99:15)
    at processPromiseRejections (internal/process/promises.js:140:9)
    at processTicksAndRejections (internal/process/next_tick.js:82:32)

1 个答案:

答案 0 :(得分:0)

如果我在30天前从字面上更新了该插件,该插件如何过旧/过旧?

请像往常一样在Github存储库上报告问题,以及显示问题的项目,以便我重现。

跟进:https://github.com/EddyVerbruggen/nativescript-nfc/issues/44