Search code examples
javadriverandroid-things

Android things: 1.0.0 Issue: Superclass com.google.android.things.pio.GpioCallback of com.google.android.things.contrib.driver.button


I have this code in github

https://github.com/neuberfran/sample-button-master

I have a issue: java.lang.IncompatibleClassChangeError:Superclass com.google.android.things.pio.GpioCallback of com.google.android.things.contrib.driver.button.Button$InterruptCallback is an interface (declaration of 'com.google.android.things.contrib.driver.button.Button$InterruptCallback' appears in /data/app/com.example.androidthings.button-,

as quoted in the topic, and stay on the line 72 below (I think)

BoardDefaults.getGPIOForButton(),
            Button.LogicState.PRESSED_WHEN_HIGH,
            KeyEvent.KEYCODE_SPACE);
    mButtonInputDriver.register();
} catch (IOException e) {
    Log.e(TAG, "Error configuring GPIO pins", e);
}

https://drive.google.com/file/d/11_HEbFc-2sxk9QXPBzTnsrScTNfomC5E/view?usp=sharing

e.g.: OS version 1.0.0 Date: May 2018 Build Number: OIM1.180327.036 Play Services: 12.5.20

Can anyone help me?


Solution

  • From Button driver for Android Things description:

    Gradle dependency

    To use the button driver, simply add the line below to your project's build.gradle, where matches the last version of the driver available on jcenter.

    dependencies {
        compile 'com.google.android.things.contrib:driver-button:<version>'
    }
    

    Now latest version is 1.0, so in your build.gradle file in dependencies section remove line

    compile'com.google.android.things.contrib:driver-button:0.3'

    (line #42) and update in line #45 driver-button version to 1.0:

    implementation 'com.google.android.things.contrib:driver-button:1.0'.

    Than, update compileSdkVersion (line 20) minSdkVersion (line 27) and targetSdkVersion (line 29) to 27 (instead of 24 and 25) and resync project.