diff --git a/bindings/bdk-kotlin/android/build.gradle b/bindings/bdk-kotlin/android/build.gradle
new file mode 100644
index 0000000..f3bcdc8
--- /dev/null
+++ b/bindings/bdk-kotlin/android/build.gradle
@@ -0,0 +1,71 @@
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+apply plugin: 'maven-publish'
+
+android {
+ compileSdkVersion 30
+
+ defaultConfig {
+ minSdkVersion 21
+ targetSdkVersion 30
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles 'consumer-rules.pro'
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+afterEvaluate {
+
+ publishing {
+ publications {
+ // Creates a Maven publication called "release".
+ release(MavenPublication) {
+ // Applies the component for the release build variant.
+ from components.release
+
+ // You can then customize attributes of the publication as shown below.
+ groupId = 'org.bitcoindevkit'
+ artifactId = 'bdk'
+ version = '0.0.1-SNAPSHOT'
+ }
+ // Creates a Maven publication called “debug”.
+ debug(MavenPublication) {
+ // Applies the component for the debug build variant.
+ from components.debug
+
+ groupId = 'org.bitcoindevkit'
+ artifactId = 'bdk-debug'
+ version = '0.0.1-SNAPSHOT'
+ }
+ }
+ }
+}
+
+dependencies {
+ implementation(project(':jvm')) {
+ exclude group: 'net.java.dev.jna', module: 'jna'
+ }
+
+ implementation 'net.java.dev.jna:jna:5.8.0@aar'
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
+ implementation 'androidx.appcompat:appcompat:1.3.0'
+ implementation 'androidx.core:core-ktx:1.5.0'
+ api "org.slf4j:slf4j-api:1.7.30"
+
+ androidTestImplementation 'com.github.tony19:logback-android:2.0.0'
+ androidTestImplementation(project(':test-fixtures')) {
+ exclude group: 'net.java.dev.jna', module: 'jna'
+ }
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+ androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
+}
diff --git a/bindings/bdk-kotlin/android/proguard-rules.pro b/bindings/bdk-kotlin/android/proguard-rules.pro
new file mode 100644
index 0000000..172980c
--- /dev/null
+++ b/bindings/bdk-kotlin/android/proguard-rules.pro
@@ -0,0 +1,26 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
+
+# for JNA
+-dontwarn java.awt.*
+-keep class com.sun.jna.* { *; }
+-keepclassmembers class * extends com.sun.jna.* { public *; }
diff --git a/bindings/bdk-kotlin/android/src/androidTest/assets/logback.xml b/bindings/bdk-kotlin/android/src/androidTest/assets/logback.xml
new file mode 100644
index 0000000..efb1f6b
--- /dev/null
+++ b/bindings/bdk-kotlin/android/src/androidTest/assets/logback.xml
@@ -0,0 +1,14 @@
+
+
+
+ %logger{12}
+
+
+ [%-20thread] %msg
+
+
+
+
+
+
+
diff --git a/bindings/bdk-kotlin/android/src/androidTest/kotlin/org/bitcoindevkit/bdk/AndroidLibTest.kt b/bindings/bdk-kotlin/android/src/androidTest/kotlin/org/bitcoindevkit/bdk/AndroidLibTest.kt
new file mode 100644
index 0000000..9e1eec0
--- /dev/null
+++ b/bindings/bdk-kotlin/android/src/androidTest/kotlin/org/bitcoindevkit/bdk/AndroidLibTest.kt
@@ -0,0 +1,21 @@
+package org.bitcoindevkit.bdk
+
+import android.app.Application
+import android.content.Context.MODE_PRIVATE
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import org.junit.runner.RunWith
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * See [testing documentation](http://d.android.com/tools/testing).
+ */
+@RunWith(AndroidJUnit4::class)
+class AndroidLibTest : LibTest() {
+ override fun getTestDataDir(): String {
+ val context = ApplicationProvider.getApplicationContext()
+ return context.getDir("bdk-test", MODE_PRIVATE).toString()
+ }
+
+}
diff --git a/bindings/bdk-kotlin/android/src/main/AndroidManifest.xml b/bindings/bdk-kotlin/android/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..c8fa4de
--- /dev/null
+++ b/bindings/bdk-kotlin/android/src/main/AndroidManifest.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
diff --git a/build.sh b/build.sh
index eaeb2cd..d94e956 100755
--- a/build.sh
+++ b/build.sh
@@ -49,6 +49,8 @@ build_kotlin() {
## rust android
build_android() {
+ build_kotlin
+
# If ANDROID_NDK_HOME is not set then set it to github actions default
[ -z "$ANDROID_NDK_HOME" ] && export ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle
@@ -61,27 +63,27 @@ build_android() {
# IMPORTANT: make sure every target is not a substring of a different one. We check for them with grep later on
BUILD_TARGETS="${BUILD_TARGETS:-aarch64,armv7,x86_64,i686}"
- mkdir -p bdk-kotlin/android/src/main/jniLibs/ bdk-kotlin/android/src/main/jniLibs/arm64-v8a bdk-kotlin/android/src/main/jniLibs/x86_64 bdk-kotlin/android/src/main/jniLibs/armeabi-v7a bdk-kotlin/android/src/main/jniLibs/x86
+ mkdir -p bindings/bdk-kotlin/android/src/main/jniLibs/ bindings/bdk-kotlin/android/src/main/jniLibs/arm64-v8a bindings/bdk-kotlin/android/src/main/jniLibs/x86_64 bindings/bdk-kotlin/android/src/main/jniLibs/armeabi-v7a bindings/bdk-kotlin/android/src/main/jniLibs/x86
if echo $BUILD_TARGETS | grep "aarch64"; then
CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="aarch64-linux-android21-clang" CC="aarch64-linux-android21-clang" cargo build --target=aarch64-linux-android
- cp target/aarch64-linux-android/debug/libbdk_ffi.so bdk-kotlin/android/src/main/jniLibs/arm64-v8a
+ cp target/aarch64-linux-android/debug/libuniffi_bdk.so bindings/bdk-kotlin/android/src/main/jniLibs/arm64-v8a
fi
if echo $BUILD_TARGETS | grep "x86_64"; then
CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER="x86_64-linux-android21-clang" CC="x86_64-linux-android21-clang" cargo build --target=x86_64-linux-android
- cp target/x86_64-linux-android/debug/libbdk_ffi.so bdk-kotlin/android/src/main/jniLibs/x86_64
+ cp target/x86_64-linux-android/debug/libuniffi_bdk.so bindings/bdk-kotlin/android/src/main/jniLibs/x86_64
fi
if echo $BUILD_TARGETS | grep "armv7"; then
CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="armv7a-linux-androideabi21-clang" CC="armv7a-linux-androideabi21-clang" cargo build --target=armv7-linux-androideabi
- cp target/armv7-linux-androideabi/debug/libbdk_ffi.so bdk-kotlin/android/src/main/jniLibs/armeabi-v7a
+ cp target/armv7-linux-androideabi/debug/libuniffi_bdk.so bindings/bdk-kotlin/android/src/main/jniLibs/armeabi-v7a
fi
if echo $BUILD_TARGETS | grep "i686"; then
CARGO_TARGET_I686_LINUX_ANDROID_LINKER="i686-linux-android21-clang" CC="i686-linux-android21-clang" cargo build --target=i686-linux-android
- cp target/i686-linux-android/debug/libbdk_ffi.so bdk-kotlin/android/src/main/jniLibs/x86
+ cp target/i686-linux-android/debug/libuniffi_bdk.so bindings/bdk-kotlin/android/src/main/jniLibs/x86
fi
# bdk-kotlin aar
- (cd bdk-kotlin && ./gradlew :android:build && ./gradlew :android:publishToMavenLocal)
+ (cd bindings/bdk-kotlin && ./gradlew :android:build && ./gradlew :android:publishToMavenLocal)
}
OS=$(uname)
@@ -95,6 +97,7 @@ else
while [ -n "$1" ]; do # while loop starts
case "$1" in
+ -a) build_android ;;
-k) build_kotlin ;;
-h) help ;;
*) echo "Option $1 not recognized" ;;
diff --git a/test.sh b/test.sh
index e46caed..e552176 100755
--- a/test.sh
+++ b/test.sh
@@ -11,13 +11,18 @@ help()
echo
echo "Syntax: build [-a|h|k|v]"
echo "options:"
+ echo "-a Android connected device tests."
echo "-h Print this Help."
echo "-k Kotlin tests."
echo
}
test_kotlin() {
- (cd bindings/bdk-kotlin && rm -rf /tmp/testdb && ./gradlew test -Djna.debug_load=true)
+ (cd bindings/bdk-kotlin && ./gradlew :jvm:test -Djna.debug_load=true)
+}
+
+test_android() {
+ (cd bindings/bdk-kotlin && ./gradlew :android:connectedDebugAndroidTest)
}
if [ $1 = "-h" ]
@@ -29,6 +34,7 @@ else
# optional tests
while [ -n "$1" ]; do # while loop starts
case "$1" in
+ -a) test_android ;;
-h) help ;;
-k) test_kotlin ;;
*) echo "Option $1 not recognized" ;;