The core team uses Debian GNU/Linux + Android Studio, latest version. It is also available for Windows and Mac, but we never used that. You can use any Android device connected to USB to run your code straight from Android Studio on the device. Be aware that you cannot install your own built version and F-Droid's at the same time. You can export and import your database, though.
You need to install
- a Java Development Kit (JDK)
- adb (Android Debug Bridge, included in Android Studio)
On Ubuntu, you can use following commands (java 9 seems broken, please use java 8)
sudo apt-get install openjdk-8-jdk git adb
Getting the code
git clone https://codeberg.org/Freeyourgadget/Gadgetbridge.git
(after you did that once, you can use
git pull to get the newest Gadgetbridge code)
Alternatively you can use Android Studio to clone the Gadgetbridge repository.
Building and installing the Gadgetbridge apk
If you only want to compile the code, you can simply execute
And install it to your mobile or tablet by executing
adb install app/build/outputs/apk/app-debug.apk
Android Studio does all this automatically when you press the
Debug button, you may have to open the root directory of the repo for the configuration to be loaded.
Short Introduction to Gadgetbridge's Source Code
- PebbleSupport (see class hierarchy)
- PebbleProtocol (pebble communication protocol)
- PebbleIOThread (background thread for pebble communication)
- MiBandSupport (see class hierarchy)
- BtLEQueue (communication queue for Bluetooth LE devices)
- DeviceCommunicationService (Android service channeling the communication with devices)
- DeviceService ("client side API" of DeviceCommunicationService, see GBApplication#deviceService())
- GBDevice (generic, device-unspecific)
- DeviceCoordinator (see class hierarchy)
- ControlCenterv2 (main activity)
All the details about the communication/protocol with a concrete device (Pebble, Mi Band, ...) is inside the "Concrete Device Impl." component, that is, the concrete implementations of the
DeviceSupport interface. Only the
DeviceCommunicationService has access to those -- clients (typically Activities) talk to the
DeviceService interface in order to communicate with the devices.
Bluetooth Error Codes
slf4j for logging, so just use
LoggerFactory.getLogger(Your.class) and log away. The output will be written to the Android Log (so you can get it with logcat or Android Studio) as well as to the file
/sdcard/Android/data/nodomain.freeyourgadget.gadgetbridge/files/gadgetbridge.log. File logging needs to be enabled in Gadgetbridge's preferences, first.
import org.slf4j.Logger; import org.slf4j.LoggerFactory; ... private static final Logger LOG = LoggerFactory.getLogger(Your.class); ... LOG.error("Error accessing database", e);`
Use one of the
nodomain.freeyourgadget.gadgetbridge.util.GB#toast() methods to display information to the user. They
- the toast when given an exception also logs warnings and errors, so with the toast you not have to use LOG afterwards.
- can safely be called from a background thread
import nodomain.freeyourgadget.gadgetbridge.util.GB; ... GB.toast("My toast message", Toast.LENGTH_SHORT, GB.ERROR, e);
greenDAO for database access. See
nodomain.freeyourgadget.gadgetbridge.daogen.GBDaoGenerator for entity definition and generation. Do note that we use greenDAO in version 2, the official greenDAO documentation already mentions version 3.
To add a column to a database, simply add a new field to a particular class in
nodomain.freeyourgadget.gadgetbridge.daogen.GBDaoGenerator, then build the project, which will trigger generating of corresponding ...dao.class files. Also, make sure to set a new schema version
Schema schema = new Schema(xx... and prepare a migration file in
All icons should be provided as vector drawables, do not use PNGs anymore. If you are drawing the original design in SVG, make sure to export as regular uncompressed SVG, because Android Studio handles these files better. Then, import it to Android Studio via right click in Project panel → New → Vector Asset → Local file. Then, use Avocado optimizer for Android VectorDrawable (VD) and AnimatedVectorDrawable (AVD) xml files. Avocado rewrites the VectorDrawable using the smallest number of s and s possible, reducing their file sizes and making them faster to parse and draw at runtime.
- Data Backup
- Permissions Explained
- Sports Activities Workouts
- Activity Sessions List
- Activity and Sleep Charts
- Heartrate measurement
- GPS recording of sports activities
- Huami devices
- MyKronoz ZeTime
- Casio devices
- Fossil Hybrid HR
- How to Release
- Developer Documentation
- BT Protocol Reverse Engineering
- Support for a new Device
- New Device Tutorial
- Translating Gadgetbridge