23 Developer Documentation
vanous edited this page 5 months ago

Development Environment

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)
  • git
  • 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 java-1.8.0-openjdk-amd64 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

./gradlew assembleDebug


./gradlew assembleRelease

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 Run or Debug button.

Short Introduction to Gadgetbridge’s Source Code

Important Classes


Overview UML Component Diagram

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



We use 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.

Information Display

Use one of the nodomain.freeyourgadget.gadgetbridge.util.GB#toast() methods to display information to the user. They

  • not only display, but also log warnings and errors
  • can safely be called from a background thread


We use greenDAO for database access. See nodomain.freeyourgadget.gadgetbridge.daogen.GBDaoGenerator for entity definition and generation.