Skip to content

Common Pitfalls

Michael Elmore edited this page Nov 5, 2023 · 2 revisions

Pitfalls and Gotchas

This document is a non-exhaustive list of the common errors a developer might encounter when creating a new driver for the app.

Gradle

Gradle is a powerful and comprehensive build tool, but on large multi-module projects, it can sometimes cause a little grief.

  1. When building a driver in osh-addons or some similar repository, if the driver requires Android-specific dependencies, the submodule's root project most likely will have an issue being a pure Java project
  2. Make sure your driver is included in the sensorhub-android-app project's build.gradle

UI

  1. Make sure to add the SwitchPreference and MultiSelectListPreference to res.xml.pref_sensors.xml in sensorhub-android-app to enable your sensor

Main Activity

The src.org.sensorhub.android.MainActivity.java file in sensorhub-android-app is where the app-wide setup occurs; make sure your driver is imported here as well as being added to the sensorhubConfig.

Following that, make sure to set up your driver's config file.

Resources

In the Resources folder of your driver, edit org.sensorhub.api.module.IModuleProvider to reference your driver's descriptor class.

AndroidManifest

Edit AndroidManifest.xml with the correct package.

In the Driver

The driver will mostly mimic a standard OSH driver, but some things can occur that might not be obvious.

  1. If your driver isn't being initialized or started, check that you aren't passing a null reference to the module's classname.
    • If you are, have your driver's config file extend from SensorConfig in its constructor. Use a line similar to this: this.moduleClass = [MAIN_DRIVER_NAME].class.getCanonicalName();
  2. If you require a reference to the Context, it's probably best to handle that in the config file then pass it through to your main driver file.

Clone this wiki locally