NFC Mifare Ultralight Tag write error

442 views
Skip to first unread message

Ajith Kamath

unread,
May 16, 2011, 2:04:10 AM5/16/11
to Android Developers, android-...@googlegroups.com
Hi all
 
I am trying to write Ndef message into Mifare Ultralight Tag.
But I am getting following error:

05-12 17:50:04.686: INFO/ActivityManager(121): Starting: Intent { act=android.nfc.action.NDEF_DISCOVERED dat=tel:xxx-xxx-xxxx flg=0x30000000 cmp=com.android.apps.tag/.WriteTagActivity (has extras) } from pid -1
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566): Failed to write tag
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566): java.io.IOException: Tag is not ndef
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.nfc.tech.Ndef.writeNdefMessage(Ndef.java:211)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at com.android.apps.tag.WriteTagActivity.writeTag(WriteTagActivity.java:173)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at com.android.apps.tag.WriteTagActivity.onNewIntent(WriteTagActivity.java:136)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1119)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:1722)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.app.ActivityThread.performNewIntents(ActivityThread.java:1734)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.app.ActivityThread.handleNewIntent(ActivityThread.java:1742)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.app.ActivityThread.access$2300(ActivityThread.java:117)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:978)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.os.Looper.loop(Looper.java:123)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at android.app.ActivityThread.main(ActivityThread.java:3683)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at java.lang.reflect.Method.invokeNative(Native Method)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at java.lang.reflect.Method.invoke(Method.java:507)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-12 17:50:04.799: ERROR/com.android.apps.tag.WriteTagActivity(566):     at dalvik.system.NativeStart.main(Native Method)
05-12 17:50:04.799: INFO/com.android.apps.tag.WriteTagActivity(566): in onResume() mAdapter!=null
05-12 17:50:04.912: ERROR/NFC JNI(248): phLibNfc_RemoteDev_CheckPresence() returned 0x00ff[NFCSTATUS_FAILED]
 
 
I had enabled WriteTagActivity.java and was trying the write application.
Problem is that the code block from where this IOException is occuring tells me that the tag is already Ndef formatted.
 
heres the block  which gets excecuted:
 
Ndef ndef = Ndef.get(tag);
            if (ndef != null) {
                ndef.connect();
                if (!ndef.isWritable()) {
                    setStatus("Tag is read-only.", false);
                    return false;
                }
                if (ndef.getMaxSize() < mSize) {
                    setStatus("Tag capacity is " + ndef.getMaxSize() + " bytes, message is " +
                            mSize + " bytes.", false);
                    return false;
                }
                ndef.writeNdefMessage(mMessage);
                setStatus("Wrote message to pre-formatted tag.", true);
                return true;
 
 
Since ndef!=null block is getting executed, i presume its already ndef formatted.
I don't get "Tag is read-only." or "Tag capacity is " errors..
Exception is happening  when ndef.writeNdefMessage(mMessage) is executed
 
Let me know if anyone knows why this error is occuring.
 
Thanks & Regards,
Ajith

John Hunter

unread,
Jun 21, 2011, 5:00:09 PM6/21/11
to android-...@googlegroups.com, Android Developers
Hi Ajith,

I am encountering the same problem.
Did you figure out what was causing the IO exception on the write?

-John

Ajith Kamath

unread,
Jun 21, 2011, 10:37:36 PM6/21/11
to android-...@googlegroups.com, Android Developers
Hi John

I only had one tag - Mifare Ultralight. I haven't figured out the solution for this error.
I think it might be the tag error. But I'm not able to prove my contention.
Please let me know if the same thing is happening with multiple tags. Kindly send your logs too.

Regards,
Ajith


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-platform/-/rYqfkqjKEsAJ.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.

Omar Seyal

unread,
Jul 21, 2011, 3:46:52 AM7/21/11
to android-platform
Hi Ajith,

Any progress on this?

I'm encountering this issue as well. It works fine when writing to
Mifare 1K Classics (which is odd, given the fact that those aren't
actually NFC Forum tags) ... but gives me an IOException when I test
with ultralights.

Cheers,
Omar

On Jun 21, 7:37 pm, Ajith Kamath <sjce.aj...@gmail.com> wrote:
> Hi John
>
> I only had one tag - Mifare Ultralight. I haven't figured out the solution
> for this error.
> I think it might be the tag error. But I'm not able to prove my contention.
> Please let me know if the same thing is happening with multiple tags. Kindly
> send your logs too.
>
> Regards,
> Ajith
>
> On Wed, Jun 22, 2011 at 6:00 AM, John Hunter
> <john.stuart.hun...@gmail.com>wrote:

Sushma Kavatekar

unread,
Jul 25, 2011, 6:28:28 AM7/25/11
to android-platform
Hi Omar,

Could you pls attach the logs of successful write on Mifare 1K Classics?

Regards,
Sushma

Reply all
Reply to author
Forward
0 new messages