I have written a Flutter plugin to implement ACS SmartCardReaders. All works fine when I build from VSCode to my device, but the plugin throws an error in the following function when I build a release version.
To be more precise, bluetoothSmartCard.getFactory() returns null whereas it returns a TerminaleFactory when I build from VSCode to my device.
I should add that bluetoothSmartCard.getManager() returns the BluetoothTerminalManager.
I am at a loss to understand why this may happen. Here is the link to the Plugin repo on GitHub.
fun connectToDevice(
activity: Activity,
context: Context,
driver: Driver,
cardTerminalType: Int,
timeoutSeconds: Int,
) {
this.activity = activity
this.driver = driver
this.context = context
this.cardTerminalType = cardTerminalType
val bluetoothSmartCard: BluetoothSmartCard = BluetoothSmartCard.getInstance(context)
mManager = bluetoothSmartCard.getManager()
if (mManager == null) {
Log.e("$TAG connectToDevice", "mManager cannot be null")
val errorMessage = "[ERROR]/[SmartCardReader.kt]/[connectToDevice] : mManager cannot be null\n"
logDataNotifier.updateState(errorMessage, methodChannel)
deviceConnectionStatusNotifier.updateState(DEVICE_CONNECTION_STATE_ERROR, methodChannel)
return
}
mFactory = bluetoothSmartCard.getFactory()
if (mFactory == null) {
Log.e("$TAG connectToDevice", "mFactory cannot be null")
val errorMessage = "[ERROR]/[SmartCardReader.kt]/[connectToDevice] : mFactory cannot be null\n"
logDataNotifier.updateState(errorMessage, methodChannel)
deviceConnectionStatusNotifier.updateState(DEVICE_CONNECTION_STATE_ERROR, methodChannel)
return
}
startScan(timeoutSeconds)
}