This project builds an .aar package for the Android platform that provide Kotlin language bindings for the bdk
library. The Kotlin language bindings are created by the bdk-ffi
project which is included in the root of this repository.
To use the Kotlin language bindings for bdk
in your Android project add the following to your gradle dependencies:
repositories {
mavenCentral()
}
dependencies {
implementation("org.bitcoindevkit:bdk-android:<version>")
}
To use a snapshot release, specify the snapshot repository url in the repositories
block and use the snapshot version in the dependencies
block:
repositories {
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
implementation("org.bitcoindevkit:bdk-android:<version-SNAPSHOT>")
}
Note that Kotlin version 1.9.23
or later is required to build the library.
- Clone this repository.
git clone https://github.com/bitcoindevkit/bdk-ffi
- Follow the "General" bdk-ffi ["Getting Started (Developer)"] instructions.
- Install Android SDK and Build-Tools for API level 30+
- Setup
ANDROID_SDK_ROOT
andANDROID_NDK_ROOT
path variables which are required by the build tool. Note that currently, NDK version 25.2.9519653 or above is required. For example:
# macOS
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/25.2.9519653
# linux
export ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
export ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/25.2.9519653
- Build kotlin bindings
# build Android library
cd bdk-android
bash ./scripts/build-<your-local-architecture>.sh
- Start android emulator and run tests
./gradlew connectedAndroidTest
cd bdk-android
./gradlew publishToMavenLocal -P localBuild
Note that the commands assume you don't need the local libraries to be signed. If you do wish to sign them, simply set your ~/.gradle/gradle.properties
signing key values like so:
signing.gnupg.keyName=<YOUR_GNUPG_ID>
signing.gnupg.passphrase=<YOUR_GNUPG_PASSPHRASE>
and use the publishToMavenLocal
task without the localBuild
flag:
./gradlew publishToMavenLocal
Depending on the JVM version you use, you might not have the JNA dependency on your classpath. The exception thrown will be
class file for com.sun.jna.Pointer not found
The solution is to add JNA as a dependency like so:
dependencies {
implementation("net.java.dev.jna:jna:5.12.1")
}
For some older versions of macOS, Android Studio will recommend users install the x86 version of the emulator by default. This will not work with the bdk-android library, as we do not support 32-bit architectures. Make sure you install an x86_64 emulator to work with bdk-android.