This Android app is a collaborative database for sighting and categorisation of Meliponini bee species in the Brazilian Amazon. This project is a collaboration between p2panda and Meli. The app runs a full p2panda node and allows decentralised and offline-first collaboration among users, it is developed with Flutter and uses the p2panda SDK for its p2p functionalities.
This is a Melos mono-repository managing both the Android application source-code and "external" Dart and Flutter libraries providing all p2panda functionality via FFI bindings.
Listed versions are the ones we used successfully in our developer environments, other versions might work well too.
⚠️ The exact NDK version is required.
- Rust
1.75.0
- Java
17
- Android SDK
34.0.0
- Android NDK
25.2.9519653
- Flutter SDK
3.22.0
and Dart SDK3.4.0
- Melos
# Install all Dart dependencies, make sure you've installed melos globally
dart pub get
# Bootstrap your Melos environment
melos bs
# Check code style and correctness
melos analyze
# Format code according to guidelines
melos format
To configure the release to connect to a relay node you will need to set
RELAY_ADDRESS
, without it the app will only discover other peers via mDNS on
a local network.
Optionally you can also set a Pre-Shared Secret via PSK
to connect to a
network protected by a shared secret.
Lastly you might want to distinct between normal
and qa
release flavors to
distinct "staging" releases from "production" ones.
# Build and obfuscate releases for all architectures
PSK="<secret>" FLAVOR=normal RELAY_ADDRESS=203.0.113.0:2022 melos release
To bring p2panda-rs
and aquadoggo
into a native Android environment
we're utilising flutter_rust_bridge
which automatically generates Dart code
with FFI bindings from Rust.
The code resides in:
packages/p2panda/native
: Rust API used in the Android applicationpackages/p2panda
: p2panda Dart packagepackages/p2panda_flutter
: p2panda Flutter package
Use the following commands for FFI package development:
# After changing the Rust code in `packages/p2panda/native` re-build the
# library. This automatically installs Android compilation targets and the
# cargo-ndk tool if missing.
#
# Additionally this script moves the native android libraries into the `app`
# folder, where they are needed.
melos build
# Bump the package versions for release (we're not releasing yet).
melos version
It is recommended to develop or run the project with Android
Studio or with the flutter-cli
command line tool.
packages/app
: Android application built with Flutter
Here are some examples on how to run the app using the Flutter command line tool:
⚠️ Setting a "Flavor" is required to build and run the .apk, either as a flutter command line argument or as a build configuration in Android Studio (Edit Configurations > Build Flavor).
# Manage emulators
flutter emulators
# Launch an emulator
flutter emulators --launch <id>
# List all device ids (emulated or physical)
flutter devices
# Run app on emulated or connected device
flutter run --flavor normal --device-id <id>
To configure your app to connect to a relay node you will need to set
RELAY_ADDRESS
with the correct ipv4 address and port number via an
environment variable or the command line like so.
flutter run --dart-define=RELAY_ADDRESS=203.0.113.0:2022
The p2panda schemas and migrations are managed in the schemas
folder with the
fishy
command line tool.
schemas
: Meli Schemas
GNU Affero General Public License v3.0 AGPL-3.0-or-later
This project has received funding from the European Union’s Horizon 2020 research and innovation programme within the framework of the NGI-POINTER Project funded under grant agreement No 871528