You need to have the following Android developer tools installed:
- "Android SDK Platform-tools" version 28.0.2 recommended
- "Android SDK Tools" version 26.1.1
- "Android SDK Build-tools" version 28.0.3
- "Android Support Library" version 28.0.0
The above tools can be installed from the Android SDK manager.
Clone the repo
git clone https://github.com/Blockstream/green_android.git
How to build
Use the released native libraries (recommended):
The pre-built native libraries are the same versions used in the builds published by GreenAddress. Gradle/Android Studio will automatically use the latest.
Cross-compile the native libraries (advanced):
If you wish to make changes to the native libraries or would like to build completely from source, you can compile gdk from its source code yourself.
This requires the "Android NDK" (version r19b recommended) from Android developer tools, as well as SWIG. Most Linux distributions have SWIG available, on debian for example you can install it using:
sudo apt-get install swig
You must set the environment variables
correctly, then run:
cd app && ./prepare_gdk_clang.sh && cd ..
If you get errors building please ensure your are using the recommended NDK version.
Build the Android app
This will build both release and debug builds.
You can speed up builds by limiting the tasks which run. Use:
To see a list of available tasks.
Rebuild the checkpoints (optional)
Checkpoint files reduce the amount of data that SPV has to download. The checkpoint data is rebuilt periodically but you may wish to update it if you will be making and testing changes.
To rebuild, start both MAINNET and TESTNET instances of bitcoind on localhost. Make sure they are fully synchronized and have finished booting (verifying blocks, etc).
./gradlew --project-dir=bitcoinj/tools buildMainnetCheckpoints && mv bitcoinj/tools/checkpoints app/src/main/assets/production/checkpoints
./gradlew --project-dir=bitcoinj/tools buildTestnetCheckpoints && mv bitcoinj/tools/checkpoints-testnet app/src/main/assets/btctestnet/checkpoints
Or to build both at once, run:
Rebuilding with docker (optional)
If you have docker configured and want to build the app in release mode without having to set up an Android development environment, run:
cd contrib docker build -t greenbits_docker . docker run -v $PATH_TO_GREENBITS_REPO:/gb greenbits_docker
If you don't need to build the Docker image, you can instead run:
docker pull greenaddress/android && docker run -v $PATH_TO_GREENBITS_REPO:/gb greenaddress/android
Thanks to Bitcoin Wallet for Android for their QR scanning activity source code!