Search code examples
javauartandroid-thingsandroid-gpsnmea

Android-Things GpsService Not Initilizing


Using Android Studio's auto-generated GPS code, during setupGps the NmeaGpsDriver fails to initialize.

Logcat Code:

2019-03-23 18:19:30.590 2054-2054/com.example.gpsmonitor I/InstantRun: starting instant run server: is main process
2019-03-23 18:19:30.602 2054-2054/com.example.gpsmonitor I/ActivityThread: handleStopService: token=android.os.BinderProxy@1bda8fc not found.
2019-03-23 18:19:30.614 2054-2054/com.example.gpsmonitor D/GpsService: GpsService: onCreate
2019-03-23 18:19:30.614 2054-2054/com.example.gpsmonitor D/GpsService: GpsService: setupGps
2019-03-23 18:19:30.669 2054-2054/com.example.gpsmonitor I/zygote: Rejecting re-init on previously-failed class java.lang.Class<com.google.android.things.contrib.driver.gps.NmeaGpsModule$1>: java.lang.IncompatibleClassChangeError: Superclass com.google.android.things.pio.UartDeviceCallback of com.google.android.things.contrib.driver.gps.NmeaGpsModule$1 is an interface (declaration of 'com.google.android.things.contrib.driver.gps.NmeaGpsModule$1' appears in /data/app/com.example.gpsmonitor-TvGQRLdwcqrtDMbhjtBn1Q==/split_lib_dependencies_apk.apk)
2019-03-23 18:19:30.670 2054-2054/com.example.gpsmonitor I/zygote:     at void com.google.android.things.contrib.driver.gps.NmeaGpsDriver.<init>(android.content.Context, java.lang.String, int, float, android.os.Handler) (NmeaGpsDriver.java:67)

It is almost entireley the auto-generated code from Android Studio for Things with Peripherals and set the UART6 for the Pico-Pi-i.MX7d. So I'm wondering what I'm missing.


Solution

  • This is because the Android Studio template is pulling in an older version of the GPS driver that is not compatible with your device. Most likely you just need to update the dependency version in your build.gradle to 1.0:

    dependencies {
        implementation 'com.google.android.things.contrib:driver-gps:1.0'
        compileOnly 'com.google.android.things:androidthings:1.0'
    }
    

    If that causes you any issues you can also take a look at the GPS driver sample, which is up to date with the 1.0 driver.