DESFire.getDFName throws exception

Forum / MIFARE SDK / DESFire.getDFName throws exception

  • 9. June 2015 at 18:56
    Hi all,

    I'm just trying to get the DFNames of a card and doing this:
                        Log.i(TAG, "Connecting...");
    objDESFireEV1.connectL4();

    Log.i(TAG, "Seleccionando aplicación PICC...");
    objDESFireEV1.selectApplication(0);
    Log.i(TAG, "Leyendo aplicaciones");
    ArrayList dfNames = objDESFireEV1.getDFName();
    Iterator dfNameIterator = dfNames.iterator();
    while(dfNameIterator.hasNext()) {
    DESFire.DFName dfName = dfNameIterator.next();
    Log.i(TAG, "AID: " + Integer.toString(dfName.getAID()));
    }

    I get an exception like this one:

    06-09 19:30:40.190 10585-10585/com.paynopain.desfire.desfirereader W/System.err﹕ java.lang.ArrayIndexOutOfBoundsException
    06-09 19:30:40.200 10585-10585/com.paynopain.desfire.desfirereader W/System.err﹕ at java.util.Arrays.copyOfRange(Arrays.java:2695)
    06-09 19:30:40.200 10585-10585/com.paynopain.desfire.desfirereader W/System.err﹕ at com.nxp.nfclib.desfire.DESFire.getDFName(:3106)
    06-09 19:30:40.200 10585-10585/com.paynopain.desfire.desfirereader W/System.err﹕ at com.paynopain.desfire.desfirereader2.ReaderActivity$1.onDESFireCardDetected(ReaderActivity.java:157)
    06-09 19:30:40.200 10585-10585/com.paynopain.desfire.desfirereader W/System.err﹕ at com.nxp.nfclib.Interface.NxpNfcLib.ˎ(:438)
    06-09 19:30:40.200 10585-10585/com.paynopain.desfire.desfirereader W/System.err﹕ at com.nxp.nfclib.Interface.NxpNfcLib.filterIntent(:373)
    06-09 19:30:40.200 10585-10585/com.paynopain.desfire.desfirereader W/System.err﹕ at com.paynopain.desfire.desfirereader2.ReaderActivity.onNewIntent(ReaderActivity.java:204)


    What I'm doing wrong?
    + 0  |  - 0

    Re: DESFire.getDFName throws exception

    9. June 2015 at 20:16
    First things first - your error is not related to SDK. Since that is what you see in Log. It's SYSTEM ERROR: ArrayIndexOutOfBounds.

    Next, let me try to help nevertheless:
    With this code sample I cannot see where the error could occur. But that error means that you you are trying to access some values in your ArrayList that are not filled.
    Example:
    dfNames.add("Test1");
    dfNames.add("Test2");

    And then if you try to access:

    dfNames.get(3);

    It will throw you ArrayOutOfBounds.

    But can't say if this is the case with you. Could you tell me more about your code and mark the CODE LINE where it points this error to.

    Best,
    David
    + 0  |  - 0
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.