0

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

neuberfran
  • 359
  • 3
  • 18
  • 1
    You should update your device operating system and the library to version 1.0.0 as a number of APIs have changed or been updated. – Nick Felker Jul 02 '18 at 19:45
  • @NickFelker How to I do this without necessarily pulling another install image and burning a sd card? – neuberfran Jul 02 '18 at 23:02
  • 2
    If you're still on the developer preview, your best bet is to install a new image. After that you'll be able to create new images and OTA update them to the device. – Nick Felker Jul 03 '18 at 01:50
  • @NickFelker I create: OS version 1.0.1 (latest). I can run motors with pio i2c I2C1 0x1B write-raw 0x46 128 0x05 0x00 0xD1. But 1.0.1 not exist and compileOnly 'com.google.android.things:androidthings:1.0' I have this issue: https://drive.google.com/file/d/1OeDRh23QEr0utkWrDglhI9iNjS4Z6ABS/view?usp=sharing https://drive.google.com/file/d/10hCYyfJ0PGw0QflMiVjc12f-7B9h0Ryz/view?usp=sharing – neuberfran Jul 03 '18 at 19:15
  • 1
    compileOnly 'com.google.android.things:androidthings:1.0' is the latest dependency. As you're seeing the permissions issue, you should add the permission to your manifest and then install the app again and then do a reboot. – Nick Felker Jul 03 '18 at 20:09
  • @NickFelker I do this: https://stackoverflow.com/questions/50752416/how-to-fix-java-lang-securityexception-caller-lacks-required-permission-com-goo see my manifest now pls: https://drive.google.com/file/d/1eIJm0bSiaPSavNZQLZwcp_2Jet4lNTPv/view?usp=sharing But now I have this issue: https://drive.google.com/file/d/18bife-nnTQU78o8yPsaDr2GUsrEUjP5T/view?usp=sharing and this: https://drive.google.com/file/d/1U6Dmw_i2YW-ZtHPYcndSc5sNNvJJdXXF/view?usp=sharing – neuberfran Jul 03 '18 at 21:01
  • @NickFelker, hI, Do you can help me more in question above – neuberfran Jul 04 '18 at 16:50
  • I solved with 3 changes: 1 - installed AT OS 1.0.1, 2 - put compileOnly 'com.google.android.things:androidthings:1.0' in build.gradle (module), 3 - change: try { PeripheralManager manager = PeripheralManager.getInstance(); device = manager.openI2cDevice(I2C_DEVICE_NAME, I2C_ADDRESS); } catch (IOException e) { Log.w(TAG, "Unable to access I2C device", e); } to: device = PeripheralManager.getInstance().openI2cDevice(i2cName, i2cAddress) – neuberfran Jul 05 '18 at 13:33

1 Answers1

1

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.

shalafi
  • 3,926
  • 2
  • 23
  • 27