I have an FMX self-service application designed to run on kiosks/tablets with printers and scanners.
The application already works on various device models by integrating with their respective AAR/JAR libraries provided by the manufacturers (extracting the .jar files and generating the JNI interface using java2op).
This past month, I have been working on integrating two devices sent by a new manufacturer: the Mini Kiosk Model and the Plus Kiosk Model.
According to the manufacturer, the same AAR and method calls are used for both devices.
On the Mini Kiosk, I was able to make everything work without any issues. However, on the Plus Kiosk, which should work the same way, Delphi returns the following error:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.HashMap android.hardware.usb.UsbManager.getDeviceList()' on a null object reference.
So i created a test project in Java that worked fine on both devices, the issue is not with the AAR itself.
After talking to the manufacturer’s support, I was advised that the Plus Kiosk requires the startup-runtime-1.1.0 library (Startup Runtime initializes objects and components automatically when the application starts).
I checked the manifest.xml inside the AAR and found the following declaration:
<application>
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge" >
<meta-data
android:name="com.e1.Comunicacao.ConUSB"
android:value="androidx.startup" />
<meta-data
android:name="com.e1.Pagamento.Brigde.ConfigFileInitializer"
android:value="androidx.startup" />
</provider>
</application>
This explains the "null object reference" error, as the UsbManager class is not being initialized properly.
However, as far as I understand, Delphi already includes this library internally.
So I am looking for suggestions on how I can try to solve this issue:
Is there a way to check if startup-runtime is correctly interacting with the manufacturer's libraries?
Do I need to regenerate the JNI interface, adding startup-runtime to it? (I’m going to try this now, but I don’t see much sense in doing so.)
Can someone please help me? I've already spent several days trying to understand and fix this error.