androidkotliniotandroid-thingsandroid-things-console

Android things: DP 7 retired PeripheralManagerService and I have issue with PeripheralManager


I have 1 project based on this: https://github.com/Nilhcem/i2cfun-androidthings
https://github.com/neuberfran/SmartDrive5 (the latter is my project)

But, when I change PeripheralManagerService to PeripheralManager (DP 7 and APi level 27)

 try {
            PeripheralManager manager = PeripheralManager.getInstance();
            mDevice = manager.openI2cDevice(I2C_DEVICE_NAME, I2C_ADDRESS);
        } catch (IOException e) {
            Log.w(TAG, "Unable to access I2C device", e);
        }

I have this issue: https://drive.google.com/file/d/1kXfknYcu4RUF7AT1549_sjJiVSG2_Jjo/view?usp=sharing in this line: https://drive.google.com/file/d/1nTXOV0qiQDe5XldzIuLsY26oIdyfs3x3/view?usp=sharing

I know about this: PeripheralManagerService throws NoClassDefFoundError but not solved.

Can you help me


Solution

  • The class not found exception means that peripheral manager is not on the operating system. You are trying to use a new API on a device that has an older version.

    You need to have the Android things library dependency in sync with the version installed on your device.

    And as it has been suggested, you should get everything into the stable release.