2

I am trying to use com.google.android.things:androidthings for UART communication. The problem I get is that PeripheralManager.getInstance() throws java.lang.RuntimeException: Stub!.

I am using a device Rockchip RK3368 with Android SDK 25.

I was following the guide from Android documentation: https://developer.android.com/things/sdk/pio/uart

PeripheralManager manager = PeripheralManager.getInstance();

The stacktrace is the following:

W/System.err: java.lang.RuntimeException: Stub!
        at com.google.android.things.pio.PeripheralManager.getInstance(PeripheralManager.java:21)
        at com.eurotronik.library.common.serial.SerialClass.<init>(SerialClass.java:38)
        at com.eurotronik.nursetabmode.serialport.SerialPortService.onCreate(SerialPortService.java:112)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3192)
        at android.app.ActivityThread.-wrap5(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1568)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6121)
        at java.lang.reflect.Method.invoke(Native Method)

What does Stub! mean and how do I fix this?

Timisorean
  • 1,388
  • 7
  • 20
  • 30
Miha Bogataj
  • 298
  • 2
  • 19
  • Possible duplicate of [remote service call PeripheralManager.getInstance](https://stackoverflow.com/questions/50603035/remote-service-call-peripheralmanager-getinstance) – Muhammad Awais Oct 08 '19 at 08:59

1 Answers1

1

A stub is an empty function. These are usually placeholders that are meant to be filled out in future versions of a library.

In your case, since you are targeting Android SDK 25, you probably don't have the latest version of the libraries in which the stubs would be filled out with real code.

From the Android docs on "Creating an Android Things Project":

Before you begin building apps for Things, you must:

  • Update your SDK tools to version 25.0.3 or higher The updated SDK tools enable you to build and test apps for Things.

  • Update your SDK with Android 8.1 (Oreo), API 27 or higher The updated platform version provides new APIs for Things apps.

FWIW, I had the same problem with a different 'things' class, the BluetoothConnectionManager. Unfortunately, my Android build doesn't permit me to update to the necessary API level.

I hope you have better luck.

Sammy I.
  • 2,523
  • 4
  • 29
  • 49