I want to read data from an NfcB type card using the NFC feature of Samsung Nexus S. I am able to recognize the card. But when I try to get an object of NfcB using get:
Tag tg=(Tag)nfcTag;
NfcB myTag = NfcB.get(tg);
I get this error:
ERROR/AndroidRuntime(808): java.lang.NoClassDefFoundError: android.nfc.tech.NfcB
Also I get an error if I use this method:
Parcelable nfcTag = intent.getParcelableExtra("android.nfc.extra.TAG");
Tag tag= (Tag)nfcTag;
tag.getTechList()
ERROR/AndroidRuntime(2498): java.lang.NoSuchMethodError: android.nfc.Tag.开发者_运维问答getTechList
The project builds correctly but at run time I get these error. If I can resolve the error I will be able to read the data. I am familiar with the APDU commands but I am not able to create the NfcB object or IsoDep object. Everything else works fine from this api.
Can anybody tell me if there is something wrong with the code or I need to use some other methods or api.
Thanks in advance
java.lang.NoClassDefFoundError from javadocs:
Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found.
Sounds like it can't find your class. Check if class belongs to a jar and jar was not added into classpath.
Also try to set permissions in the Android manifest file. See here.
精彩评论