Serial connection error: java.lang.NoClassDefFoundError: android.hardware.usb.UsbManager

Hello,
I am trying to use the serial component but every time I attempt to initialize and open the serial connection I get the following run time error: java.lang.NoClassDefFoundError: android.hardware.usb.UsbManager. My blocks are really simple as I'm just trying to focus and debug the aforementioned issue. Any help or advice would be appreciated. Thanks.



Welcome.

  1. You appear to be using the OTG extension described here>Serial OTG. Arduino CH340. FTDI. rkl099's Extension - #2 by Juan_Antonio and not the Serial component located in the App Inventor Connections bin.

The extension Blocks are named SerialOTG1 (what you seem to be trying to use); the App Inventor component Blocks are named Serial1.

To use the extension, your Android device needs to be OTG capable. Is your's? Do you have an OTG cable?

Regarding the extension: In the mobile Settings . Additional Settings. You must activate OTG

Hi Steve,
Thanks for the reply. I attempted with the App Inventor serial component blocks first and I get the same error at run time. I was using the extension to see if that changed anything.


I was using the emulator first in order to test. Is it the emulator that is causing this error? And will it be resolved if I run the app on my android device?

probably yes

you might want to try it...
let us know what you find out...

Taifun

1 Like

I think its difficult to use USB OTG with the emulator. I have always used a phone/tablet with AI Companion or installed apps for my testing.

One note: Initialize is implemented to be used once. I normally put it in whenScreen1.Initialize.

You often have to call open twice, first to get permission to use the adapter, next time to open the connection.