Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Unable to read any tag D/PersonaManager(): isNFCAllowed #14

Closed
RaMb3asT opened this issue Sep 27, 2019 · 19 comments
Closed

Unable to read any tag D/PersonaManager(): isNFCAllowed #14

RaMb3asT opened this issue Sep 27, 2019 · 19 comments

Comments

@RaMb3asT
Copy link

To test out reading RFID tags, I used the example code provided on the repository. The application runs but when I press on Start reading and consecutively try to scan a tag, I get a response from the device that the tag is found(usually vibration), however the scanned tag does not appear on the screen.

Here is an overview of the log:

Syncing files to device SM A320FL...

D/libGLESv2(30340): STS_GLApi : DTS is not allowed for Package : com.oce.flutter_app_nfc

D/libGLESv1(30340): STS_GLApi : DTS is not allowed for Package : com.oce.flutter_app_nfc

W/libc    (30340): It seems that pthread_join() is not invoked or PTHREAD_ATTR_FLAG_DETACHED is not set.

W/libc    (30340):     pthread tid          : 30402

W/libc    (30340):     pthread start_routine: 0xdfda18e7

W/libc    (30340): It seems that pthread_join() is not invoked or PTHREAD_ATTR_FLAG_DETACHED is not set.

W/libc    (30340):     pthread tid          : 30381

W/libc    (30340):     pthread start_routine: 0xdfda18e7

D/ViewRootImpl(30340): ViewPostImeInputStage processPointer 0

D/ViewRootImpl(30340): ViewPostImeInputStage processPointer 1

D/PersonaManager(30340): isNFCAllowed
@semlette
Copy link
Owner

I don't know anything about reading RFID tags using NFC on Android, except that it is possible.
Could you tell me a bit more about your tags, specifically if they're empty or if their content conform to the NDEF standard?

@RaMb3asT
Copy link
Author

As far as I am concerned, they conform to the NDEF standard as I am able to scan them using NFC readers from the App store. The tags are attached to ink containers and contain data regarding the contents of the container like product type, ink color, production date, etc. Each of these fields is placed on a separate block of the memory content of the tag. The tech they use is NfcV.

@semlette
Copy link
Owner

Hm, I'm not sure what is causing this.

Could you try the following things

  • Open example/lib/main.dart and add the readerMode: NFCDispatchReaderMode() argument to readNDEF() on line 28.

  • Open android/src/main/java/me/andisemler/nfc_in_flutter/NfcInFlutterPlugin.java and add Log.e(LOG_TAG. "!! NOT NDEF !!") under line 164 and line 205.
    After that, try scanning some tags and see if the logs contains NfcInFlutterPlugin: !! NOT NDEF !!

@RaMb3asT
Copy link
Author

Alright, I did that but there isn't any change to what is happening or to the logs.
Thanks for the quick response anyway!

@semlette
Copy link
Owner

I've just created a new branch logs which has a few more log statements. Could you checkout the branch and see if anything different happens?

@semlette
Copy link
Owner

Also, try adding

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

to your Activity in your AndroidManifest.xml and setting the readerMode to NFCDispatchReaderMode() again.

Haven't a clue if this will change anything but one can always hope 😅

@RaMb3asT
Copy link
Author

Okay, I think this might be the problem - the tag format not being supported, from the logs:
W/NfcInFlutterPlugin( 9212): received unsupported ACTION_TAG_DISCOVERED intent

@semlette
Copy link
Owner

I have pushed some changes to the logs branch. Could you try again?

@RaMb3asT
Copy link
Author

RaMb3asT commented Sep 27, 2019

Weird, the app crashes with that as a log:

E/AndroidRuntime(22673): FATAL EXCEPTION: main
E/AndroidRuntime(22673): Process: com.oce.flutter_app_nfc, PID: 22673
E/AndroidRuntime(22673): java.lang.NullPointerException: Attempt to invoke virtual 
method 'android.nfc.NdefRecord[] android.nfc.NdefMessage.getRecords()' on a null object reference
E/AndroidRuntime(22673): at me.andisemler.nfc_in_flutter.NfcInFlutterPlugin.formatNDEFMessageToResult
(NfcInFlutterPlugin.java:217)
E/AndroidRuntime(22673): 	at me.andisemler.nfc_in_flutter.NfcInFlutterPlugin.handleNDEFTagFromIntent
(NfcInFlutterPlugin.java:211)
E/AndroidRuntime(22673): 	at me.andisemler.nfc_in_flutter.NfcInFlutterPlugin.onNewIntent
(NfcInFlutterPlugin.java:203)

Edit:
Also, now I checked that on another tag it does not crash but I get:
W/NfcInFlutterPlugin(11649): tag does not support NDEF technology

@semlette
Copy link
Owner

I have pushed some more changes to the logs branch which should (hopefully) fix the crash.

@RaMb3asT
Copy link
Author

Unfortunately, it still has the same behaviour. Crash on one tag, same output on the other. The one, it crashes on has an empty/weirdly written in data on the first memory block.

@semlette
Copy link
Owner

I think I see why it still crashes, but I'm not sure why the tag won't work.

onNewIntent receiving the action NfcAdapter.ACTION_TAG_DISCOVERED and not NfcAdapter.ACTION_NDEF_DISCOVERED would suggest Android didn't recognise the content as a NDEF message, and then crashing because of a mistake in my code.

Have you tried using other NFC libraries for Flutter to see if it works with them?

@semlette
Copy link
Owner

I have pushed another update to the logs branch.

@RaMb3asT
Copy link
Author

I will check it out again on Monday when I go back to work. In regards to other libraries, I tried flutter_nfc_reader and nfc, but with no success either.

@RaMb3asT
Copy link
Author

It still crashes for me with the same output.

@semlette
Copy link
Owner

How peculiar...

Was this with the NFCDispatchReaderMode()?

Also, could you try scanning the tag using the NFC Tools app and send me a screenshot (either here or by e-mail). Specifically the section with the message records.
If the records contain any sensitive information, just blur it out. I am only interested in the media types of the records.

@RaMb3asT
Copy link
Author

Yes, it was with the NFCDispatchReaderMode().

Here are the images, hope they are sufficient:
Screenshot_20190930-092305_NFC Tools
Screenshot_20190930-092343_NFC Tools

@semlette
Copy link
Owner

This explains a few things.

The tag doesn't support the "android.nfc.tech.Ndef technology" (see Technologies available in the first screenshot) which is a deal breaker, as it is currently required by nfc_in_flutter.
The NdefFormatable only allows writing NDEF messages, but not retrieving.

As it stands right now, your tag is not usable with nfc_in_flutter, as a new API would have to be introduced to support the NfcV technology.
I do have plans to add such API in the future, but I'm working on a new release that has top priority. Plus I don't actually have any cards to test it with, so I'll have to acquire some first.

@RaMb3asT
Copy link
Author

Alright, I understand, thank you for the time and effort!

haizadvnet pushed a commit to haizadvnet/nfc_in_flutter that referenced this issue Apr 5, 2024
Add writing NDEF records of multiple types to example app
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants