nfcim/flutter_nfc_kit

Read NDEF Error

Fanom2813 opened this issue · 1 comments

Hello ! i am getting the following error when reading NDEF


E/im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin(14636): Read NDEF Error
E/im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin(14636): java.io.IOException
E/im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin(14636): 	at android.nfc.tech.BasicTagTechnology.connect(BasicTagTechnology.java:88)
E/im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin(14636): 	at android.nfc.tech.Ndef.connect(Ndef.java:71)
E/im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin(14636): 	at im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin$handleMethodCall$switchTechnology$1.invoke(FlutterNfcKitPlugin.kt:98)
E/im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin(14636): 	at im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin$handleMethodCall$switchTechnology$1.invoke(FlutterNfcKitPlugin.kt:92)
E/im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin(14636): 	at im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin$handleMethodCall$4.invoke(FlutterNfcKitPlugin.kt:192)
E/im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin(14636): 	at im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin$handleMethodCall$4.invoke(FlutterNfcKitPlugin.kt:190)
E/im.nfc.flutter_nfc_kit.FlutterNfcKitPlugin(14636): 	at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
E/flutter (14636): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(500, Communication error, null, null)
E/flutter (14636): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
E/flutter (14636): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:322:18)
E/flutter (14636): <asynchronous suspension>
E/flutter (14636): #2      FlutterNfcKit.readNDEFRawRecords (package:flutter_nfc_kit/flutter_nfc_kit.dart:385:9)
E/flutter (14636): <asynchronous suspension>
E/flutter (14636): #3      FlutterNfcKit.readNDEFRecords (package:flutter_nfc_kit/flutter_nfc_kit.dart:372:13)
E/flutter (14636): <asynchronous suspension>
E/flutter (14636): #4      MainController.contactlessPayment (package:controller.dart:573:26)
E/flutter (14636): <asynchronous suspension>
E/flutter (14636): 

I got the same error due to silly mistake on my code. Turns out it because I put FlutterNfcKit.finish(); in between FlutterNfcKit.poll(..) and FlutterNfcKit.readNDEFRecords.