Free as in Freedom: Create your repos!
Developer Documentation
MagicFab edited this page 2 months ago

Development Environment

The core team uses Debian GNU/Linux + Android Studio 2.2 (as of November 2016). 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

(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.

Extracting CSV Data from the SQLite Database

The Gadgetbridge activity database can be exported to SQLite format to extract its data for further analysis.

Under the main menu, go to Database management. Exported data will be in the Gadgdetbridge file under a directory shown on the screen.

For this example we’ll assume the file to be /storage/emulated/0/Android/data/nodomain.freeyourgadget/files/Gadgdetbridge.

This shows how to access the database from Debian GNU/Linux 9, the sqlite3 and android-tools-adb packages are required.

To list all tables in the database:

$ adb shell
OnePlus3:/ $ su
OnePlus3:/ # cd /storage/emulated/0/Android/data/nodomain.freeyourgadget.gadgetbridge/files
OnePlus3:/ # sqlite3 Gadgetbridge
SQLite version 3.19.4 2017-08-18 19:28:12
Enter ".help" for usage hints.
sqlite> .table

DEVICE                          PEBBLE_MORPHEUZ_SAMPLE        
DEVICE_ATTRIBUTES               TAG                           
HPLUS_HEALTH_ACTIVITY_OVERLAY   USER                          
NO1_F1_ACTIVITY_SAMPLE          android_metadata 

To export to CSV:

sqlite> .headers on
sqlite> .mode csv
sqlite> .output out.csv
sqlite> select * from BASE_ACTIVITY_SUMMARY;

Reference: SO.

Bluetooth Error Codes