Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDef Reader and Writer Demos Fail with the Following Stack Trace: #2

Open
brennydoogles opened this issue Mar 8, 2013 · 3 comments

Comments

@brennydoogles
Copy link

Exception in thread "Thread-0" java.lang.RuntimeException:     java.lang.IllegalArgumentException: keyConfig cannot be null
    at org.nfctools.spi.acs.PollingCardScanner.run(PollingCardScanner.java:51)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalArgumentException: keyConfig cannot be null
    at org.nfctools.mf.mad.AbstractMad.<init>(AbstractMad.java:52)
    at org.nfctools.mf.mad.Mad1.<init>(Mad1.java:34)
    at org.nfctools.mf.mad.MadUtils.createApplicationDirectory(MadUtils.java:127)
    at org.nfctools.mf.ndef.MfNdefWriter.writeNdefMessage(MfNdefWriter.java:101)
    at org.nfctools.mf.ndef.MfNdefWriter.writeNdefMessage(MfNdefWriter.java:92)
    at     org.nfctools.examples.ndefwriter.NdefWriterDemo.cardDetected(NdefWriterDemo.java:52)
    at org.nfctools.spi.acs.PollingCardScanner.waitForCard(PollingCardScanner.java:61)
    at org.nfctools.spi.acs.PollingCardScanner.run(PollingCardScanner.java:45)
    ... 1 more
@deibeeed
Copy link

i'm getting the same error.
when i traced the code, the Line states that
"Mad1 mad1 = new Mad1(null, null);"

which is Mad1 extends AbstractMad
and AbstractMad has this constructor.

public AbstractMad(MfClassicReaderWriter readerWriter, MadKeyConfig keyConfig) {
if (keyConfig == null)
throw new IllegalArgumentException("keyConfig cannot be null");
this.readerWriter = readerWriter;
this.keyConfig = keyConfig;
this.memoryLayout = readerWriter.getMemoryLayout();
}

so, if when you run NdefReaderDemo and NdefWriter demo, they will really throw you to that exception.

i dont really know the work around here i just traced the code and i can say that NdefReader and NdefWriter Demos will not work how many times you will try.

is there a way to make this work @grundid ?

@UnknownJoe796
Copy link

I know this is many years late, but for others banging their head against the wall: It's a deprecated API. The new API usage looks like this (in Kotlin):

val adapter = NfcAdapter(getAvailableTerminal(), TerminalMode.INITIATOR, object : TagScannerListener{
    override fun onScanningEnded() {
        println("onScanningEnded")
    }

    override fun onScanningFailed(throwable: Throwable?) {
        println("onScanningFailed")
    }

    override fun onTagHandingFailed(throwable: Throwable?) {
        println("onTagHandingFailed")
    }
})
adapter.registerTagListener(MfClassicNfcTagListener(object : NdefOperationsListener{
    override fun onNdefOperations(ndefOperations: NdefOperations) {
        val records = ndefOperations.readNdefMessage()
        for(record in records){
            println("Record found: " + record.toString())
        }
    }
}))

@SuneethaYamani
Copy link

TagScannerListener

Thank you this solution solved my problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants