Hello,
We are using the taplinx android SDK and are experiencing an intermittent issue on some of our devices. The following error is being thrown when trying to get the card type from a tag discovered intent:
com.nxp.nfclib.exceptions.NxpNfcLibException: TapLinX registration failed after Free Trial. Provide Valid License Key
at com.nxp.nfclib.if.apduExchange(:34)
at com.nxp.nfclib.ˋ.getReader(:67)
at com.nxp.nfclib.NxpNfcLib.getCardType(:340)
at com.nxp.nfclib.NxpNfcLib.getCardType(:278)
at com.bcom.taplinx.TapLinxHelper.readCard(TapLinxHelper.java:64)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8223)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:977)
When the application activity is created the taplinx library is registered to the activity successfully with both an online and offline key. Intermittently on some devices we receive the above error when reading a tag from intent.
We are using the following code based on the starting development guide to initialize and read tags:
public class TapLinxHelper {
public static final String TAG = "TapLinx";
// The TapLinX library instance
private NxpNfcLib tapLinxInstance = null;
public boolean IsInitialized = false;
public boolean initializeLibrary(Activity activity, String key, String offlineKey) {
tapLinxInstance = NxpNfcLib.getInstance();
try {
if(offlineKey != null && !offlineKey.isEmpty()) {
tapLinxInstance.registerActivity(activity, key, offlineKey);
}else{
tapLinxInstance.registerActivity(activity, key);
}
} catch (NxpNfcLibException ex) {
Log.d(TAG, "onNewIntent");
return false;
} catch (Exception e) {
// do nothing added to handle the crash if any
return false;
}
IsInitialized = true;
return true;
}
public void onResume() {
if (tapLinxInstance != null) {
tapLinxInstance.startForeGroundDispatch();
}
}
public void onPause() {
if (tapLinxInstance != null) {
tapLinxInstance.stopForeGroundDispatch();
}
}
public CardResult readCard(final Intent intent, int applicationID, int cardKeyNumber, byte[] applicationKey, int fileID) {
CardType cardType = tapLinxInstance.getCardType(intent); // error intermittently thrown at this point
if (cardType != CardType.DESFireEV3) {
throw new IllegalStateException("Unexpected value: " + cardType);
}
Log.d(TAG, "Card type: " + cardType.getTagName());
try {
IDESFireEV3 desFireEV3 = DESFireFactory.getInstance().getDESFireEV3(tapLinxInstance.getCustomModules());
desFireEV3.getReader().connect();
CardResult result = new CardResult();
result.CardType = desFireEV3.getType().getTagName();
result.UID = Utilities.dumpBytes(desFireEV3.getUID());
// generate the key
SecureKeyGenerator keyGenerator = SecureKeyGenerator.getInstance(tapLinxInstance.getCustomModules());
IKeyData key = keyGenerator.getKeyFromKeyBytes(applicationKey, KeyType.AES128);
// select the application
desFireEV3.selectApplication(applicationID);
// authenticate
desFireEV3.authenticate(cardKeyNumber, IDESFireEV1.AuthType.AES, KeyType.AES128, key);
// read data
result.Data = desFireEV3.readData(fileID, 0, 0);
return result;
} catch (Exception e) {
Log.d(TAG, e.getMessage());
}
return null;
}
}Are you able to offer any insight on to what might cause this error to be thrown after successfully registering the activity?
Thank you in advance for your help.
Kind Regards,
Liam