Hi, I'm facing a problem related to a device that is used in unattended mode and very often the users power it off just unplugging the power (!)
Since the device uses a Library (UART from Rui Cardoso) if the device is unplugged while writing or accessing to the serial port, at the next restart very often we get the error:
The idea is to load the LibUART.so file directly in the project and then at each APP restart, the app copy that file from the DirAssets to DireInternal.
From DirInternal then create the class, instantiate it, use methods and events.
The problem is how to do all that with B4A?
I've tried this way:
I've the JAR file. I've also included it with:
I've also added the JAR file to the File Manager in the B4A IDE, but nohing seems to work.
So, how can I replace the .so file on the fly knowing that:
- The system is unattended
- It is Android V13
- The device is not rooted
- The automated procedure I've to perform an Install intent each time the device restart, seems not to solve the problem because with "just" the corrupted libUART.so file, the app install seems to be skipped and the app does not start.
How can it is possible to solve this puzzle?
Thank you for your help.
Since the device uses a Library (UART from Rui Cardoso) if the device is unplugged while writing or accessing to the serial port, at the next restart very often we get the error:
B4X:
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/~~WarzAMVAOewFFKtPB2Sg-w==/my.package.project-FlZNlfcNG9JD37T7TosccA==/lib/arm/libUART.so" has bad ELF magic: 00000000
From DirInternal then create the class, instantiate it, use methods and events.
The problem is how to do all that with B4A?
I've tried this way:
This load successfully:
Dim jo As JavaObject
jo.InitializeStatic("java.lang.System").RunMethod("load", Array(DestinationPath & "/" & FileName))
B4X:
SerialPort = jo.InitializeNewInstance("com.project.UART", Null) ' Do not works. Never get here. See the below error
'Never get here:
jo = SerialPort
jo.RunMethod("Initialize", Array(Me, eventName_, Path_, BaudRate_, Flags_, bigEndian_, prefix_))
The error:
java.lang.ClassNotFoundException: java$lang$UART
at anywheresoftware.b4j.object.JavaObject.getCorrectClassName(JavaObject.java:289)
at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:84)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7941)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:569)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1015)
I've the JAR file. I've also included it with:
B4X:
#AdditionalJar: UART
So, how can I replace the .so file on the fly knowing that:
- The system is unattended
- It is Android V13
- The device is not rooted
- The automated procedure I've to perform an Install intent each time the device restart, seems not to solve the problem because with "just" the corrupted libUART.so file, the app install seems to be skipped and the app does not start.
How can it is possible to solve this puzzle?
Thank you for your help.