-
Notifications
You must be signed in to change notification settings - Fork 2
Common Pitfalls
This document is a non-exhaustive list of the common errors a developer might encounter when creating a new driver for the app.
Gradle is a powerful and comprehensive build tool, but on large multi-module projects, it can sometimes cause a little grief.
- 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
- Make sure your driver is included in the
sensorhub-android-appproject'sbuild.gradle
- Make sure to add the SwitchPreference and MultiSelectListPreference to
res.xml.pref_sensors.xmlinsensorhub-android-appto enable your sensor
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.
In the Resources folder of your driver, edit org.sensorhub.api.module.IModuleProvider to reference your driver's descriptor class.
Edit AndroidManifest.xml with the correct package.
The driver will mostly mimic a standard OSH driver, but some things can occur that might not be obvious.
- 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
SensorConfigin its constructor. Use a line similar to this:this.moduleClass = [MAIN_DRIVER_NAME].class.getCanonicalName();
- If you are, have your driver's config file extend from
- 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.