简体   繁体   English

从 android nfc 中的 NFC Type B (ISO 14443-3B) 读取数据; 得到 NoClassDefFoundError

[英]Reading data from NFC Type B (ISO 14443-3B) in android nfc; getting NoClassDefFoundError

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.我想使用 Samsung Nexus S 的 NFC 功能从 NfcB 类型的卡读取数据。我能够识别卡。 But when I try to get an object of NfcB using get:但是,当我尝试使用 get 获取 NfcB 的 object 时:

Tag tg=(Tag)nfcTag;
NfcB myTag = NfcB.get(tg);

I get this error:我收到此错误:

ERROR/AndroidRuntime(808): java.lang.NoClassDefFoundError: android.nfc.tech.NfcB错误/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错误/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.我熟悉 APDU 命令,但无法创建 NfcB object 或 IsoDep object。 Everything else works fine from this api. api 的其他一切工作正常。

Can anybody tell me if there is something wrong with the code or I need to use some other methods or api.谁能告诉我代码是否有问题或者我需要使用其他方法或 api。

Thanks in advance提前致谢

java.lang.NoClassDefFoundError from javadocs:来自 javadocs 的 java.lang.NoClassDefFoundError:

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.听起来它找不到你的 class。 Check if class belongs to a jar and jar was not added into classpath.检查 class 是否属于 jar 和 jar 未添加到类路径中。

Also try to set permissions in the Android manifest file.还尝试在 Android 清单文件中设置权限。 See here .这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM