SmartCardException with UltralightC and Nexus 7 2012

Forum / MIFARE SDK / SmartCardException with UltralightC and Nexus 7 2012

  • 12. May 2015 at 5:20
    Hi,
    I'm just trying the Lite SDK, using an empty UltraLight C tag with a Nexus 7 2012, with following onNewIntent method:
    protected void onNewIntent(Intent intent) {
    libInstance.filterIntent(intent, new Nxpnfcliblitecallback() {
    private String TAG;
    @Override
    public void onUltraLightCCardDetected(UltralightC objUlCardC) {
    Log.i(TAG,"UltralightC card Detected" );
    try {
    objUlCardC.connect();
    } catch (Throwable t) {
    }

    }
    });
    }

    And I get following exception:
    05-12 00:03:16.235 10520-10520/com.mifaresdktest I/SDK? This is NXP Card
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? com.nxp.nfclib.exceptions.SmartCardException: Unknown Error.
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at com.nxp.nfclib.ntag.NTag.`(:239)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at com.nxp.nfclib.ntag.NTagFactory.getNTAG(:223)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at com.nxp.nfcliblite.Interface.NxpNfcLibLite.filterIntent(:276)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at com.mifaresdktest.MainActivity.onNewIntent(MainActivity.java:80)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1210)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2430)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at android.app.ActivityThread.performNewIntents(ActivityThread.java:2443)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2452)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at android.app.ActivityThread.access$1600(ActivityThread.java:144)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
    05-12 00:03:16.369 10520-10520/com.mifaresdktest W/System.err? at android.os.Handler.dispatchMessage(Handler.java:102)
    05-12 00:03:16.370 10520-10520/com.mifaresdktest W/System.err? at android.os.Looper.loop(Looper.java:135)
    05-12 00:03:16.370 10520-10520/com.mifaresdktest W/System.err? at android.app.ActivityThread.main(ActivityThread.java:5221)
    05-12 00:03:16.370 10520-10520/com.mifaresdktest W/System.err? at java.lang.reflect.Method.invoke(Native Method)
    05-12 00:03:16.370 10520-10520/com.mifaresdktest W/System.err? at java.lang.reflect.Method.invoke(Method.java:372)
    05-12 00:03:16.370 10520-10520/com.mifaresdktest W/System.err? at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    05-12 00:03:16.370 10520-10520/com.mifaresdktest W/System.err? at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)


    Any idea what might be happening?

    Thanks!
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 8:44
    Hey manuu80!

    I think this is that weird warning due to Ultralight, NTag and maybe some other have very similar detection structure and the SDK goes through all of them (checks the blocks) to really find the right Tag.

    Can you put:

    Log.d("TAG", "Testing if it connects");

    after

    objUlCardC.connect();


    If you now see it in your logcat (the message), means your app is running forward, but it gives you warnings due to this unknown error which can occur on detection of UltraLight, NTag.
    It might be a bit annoying, but the end-user won't see the warning anyway, it is inside the Logcat only (what it could do is, to delas a bit detection of the Tag - but here we are speaking of 100ms perhaps, because it goes through all of those similar Tags).

    Hope I could explain good enough to you.
    Let me know, if you need anything else.

    BR,
    David
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 15:02
    Hi,
    thank you so much for your quick and kind response.

    I've tried what you suggested and the line it is NOT printed. Therefore:
    protected void onNewIntent(Intent intent) {
    Log.d("TAG", "Testing if it connects");
    libInstance.filterIntent(intent, new Nxpnfcliblitecallback() {
    private String TAG;
    @Override
    public void onUltraLightCCardDetected(UltralightC objUlCardC) {
    Log.i("TAG","UltralightC card Detected" );
    try {
    objUlCardC.connect();
    Log.d("TAG", "Testing if it connects");
    } catch (Throwable t) {
    }

    }
    });
    }

    And the output at logcat is:
    05-12 09:57:21.903 20861-20861/com.mifaresdktest I/SDK? This is NXP Card
    05-12 09:57:22.044 20861-20861/com.mifaresdktest W/System.err? com.nxp.nfclib.exceptions.SmartCardException: Unknown Error.
    05-12 09:57:22.044 20861-20861/com.mifaresdktest W/System.err? at com.nxp.nfclib.ntag.NTag.?(:239)
    05-12 09:57:22.044 20861-20861/com.mifaresdktest W/System.err? at com.nxp.nfclib.ntag.NTagFactory.getNTAG(:223)
    05-12 09:57:22.044 20861-20861/com.mifaresdktest W/System.err? at com.nxp.nfcliblite.Interface.NxpNfcLibLite.filterIntent(:276)
    05-12 09:57:22.044 20861-20861/com.mifaresdktest W/System.err? at com.mifaresdktest.MainActivity.onNewIntent(MainActivity.java:80)
    05-12 09:57:22.044 20861-20861/com.mifaresdktest W/System.err? at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1210)
    05-12 09:57:22.044 20861-20861/com.mifaresdktest W/System.err? at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2430)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at android.app.ActivityThread.performNewIntents(ActivityThread.java:2443)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2452)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at android.app.ActivityThread.access$1600(ActivityThread.java:144)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at android.os.Handler.dispatchMessage(Handler.java:102)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at android.os.Looper.loop(Looper.java:135)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at android.app.ActivityThread.main(ActivityThread.java:5221)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at java.lang.reflect.Method.invoke(Native Method)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at java.lang.reflect.Method.invoke(Method.java:372)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    05-12 09:57:22.045 20861-20861/com.mifaresdktest W/System.err? at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

    Thanks!
    Emmanuel.
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 15:08
    Could you please try:


    new Inxpnfcliblitecallback

    instea

    new Nxpnfcliblitecallback

    ?

    Please notify me if this changes your results.

    BR,
    David
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 15:56
    Thanks again for the quick response.

    May I ask you the import line I should use for Inxpliblitecallback class?

    I don't seem to find it

    Thanks
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 16:04
    This one should do it:

    com.nxp.nfcliblite.Interface


    BR,
    David
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 16:19
    This is great support, thanks a lot for your time!!

    Nevertheless, I can't find that exact class on that package.

    I can find something similar in that package, that's not exactly the same. The one you mentioned was: Inxpliblitecallback.

    import com.nxp.nfcliblite.Interface.Inxpnfcliblitecallback;
    [...]
    protected void onNewIntent(Intent intent) {
    Log.d("TAG", "Testing if it connects");
    libInstance.filterIntent(intent, new Inxpnfcliblitecallback() {
    private String TAG;
    @Override
    public void onUltraLightCCardDetected(UltralightC objUlCardC) {
    Log.i("TAG","UltralightC card Detected" );
    try {
    objUlCardC.connect();
    Log.d("TAG", "Testing if it connects");
    } catch (Throwable t) {
    }

    }
    });
    }

    Unfortunately, it can't compile it. It throws:
    Error:(82, 71) error: is not abstract and does not override abstract method onICodeSLIX2Detected(ICodeSLIX2) in Inxpnfcliblitecallback

    Once again, many thanks for the kind support and patience.
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 17:11
    Sorry, just noticed I confussed the classes names, so the one you suggested is the one that's complaining at compile.

    I found a similar support article that fortunately included the source code.
    http://www.mifare.net/en/micommunity/forum/mifare-sdk/android-mifare-sdk-issue/

    So I replaced my entire MainActivity.java with the source code at
    http://pastebin.com/gsN33tg8

    I had to comment a single line
    // getMenuInflater().inflate(R.menu.main, menu);

    And add the lines for the UltraLightC

    And it compiled succesfully.

    But in the other hand, the app still throws the exactle same exception, and still does not print the debug lines.

    Just in case, I put my current MainActivity.java in http://pastebin.com/QjGVLjK3

    Thanks!!
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 18:06
    I wasn't paying attention to menu's, maybe you had something undeclared there or use some theme that does not support Menu's ;)

    Yes, the exceptio gets thrown on Nexus 7, I think on other devices it wont throw you this exception! :)

    No problem!
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 18:13
    Hi, the SDK won't work on Nexus 7 with UltraLigthC? because it is not printing the line after the connect().

    public void onUltraLightCCardDetected(UltralightC arg0) {
    // TODO Auto-generated method stub
    Log.i("TAG","UltralightC card Detected" );
    try {
    arg0.connect();
    Log.d("TAG", "Testing if it connects");
    } catch (Throwable t) {
    }

    }

    Thanks!
    Emmanuel.
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 20:41
    This prints in LogCat so that we are clear, you have to check there.

    Does it print Ultralight detected ?

    David
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 20:53
    Hi,
    No it does not print that. Just to be in the same picture, I've added a print line "Going to execute filterIntent":
    [...]
    protected void onNewIntent(Intent intent) {
    Log.i("TAG","Going to execute filterIntent" );
    libInstance.filterIntent(intent, new Inxpnfcliblitecallback() {

    private String TAG;

    [...]

    And then, the complete output at LogCat is:
    05-12 15:50:31.353 20718-20718/com.mifaresdktest I/TAG? Going to execute filterIntent
    05-12 15:50:31.402 20718-20718/com.mifaresdktest I/SDK? This is NXP Card
    05-12 15:50:31.539 20718-20718/com.mifaresdktest W/System.err? com.nxp.nfclib.exceptions.SmartCardException: Unknown Error.
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at com.nxp.nfclib.ntag.NTag.?(:239)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at com.nxp.nfclib.ntag.NTagFactory.getNTAG(:223)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at com.nxp.nfcliblite.Interface.NxpNfcLibLite.filterIntent(:276)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at com.mifaresdktest.MainActivity.onNewIntent(MainActivity.java:80)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1210)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2430)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at android.app.ActivityThread.performNewIntents(ActivityThread.java:2443)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2452)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at android.app.ActivityThread.access$1600(ActivityThread.java:144)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1350)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at android.os.Handler.dispatchMessage(Handler.java:102)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at android.os.Looper.loop(Looper.java:135)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at android.app.ActivityThread.main(ActivityThread.java:5221)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at java.lang.reflect.Method.invoke(Native Method)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at java.lang.reflect.Method.invoke(Method.java:372)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
    05-12 15:50:31.540 20718-20718/com.mifaresdktest W/System.err? at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)


    Thanks!!
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 20:56
    Hi,
    might have something to do that the Tag is blank? I meant blank as defined by NXP:
    "Blank card: A MIFARE Ultralight card after production phase with its default
    setting is called blank card"

    thanks,
    Emmanuel.
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 21:00
    Please post me your current entire code in main Activity in pastebin, so that I can see what's going on.

    David
    + 0  |  - 0

    Re: SmartCardException with UltralightC and Nexus 7 2012

    12. May 2015 at 21:18
    Here it goes:
    http://pastebin.com/4jDpkgF1

    Thank you!
    + 0  |  - 0
Viewing 15 posts - 1 through 15 (of 22 total)

You must be logged in to reply to this topic.