Skip to content

Commit 286aaa0

Browse files
Expose core JNI helpers to Kotlin and demo via Android example (#33)
* Expose core JNI helpers to Kotlin and demo via Android example - add JNI wrappers for wallet ops + extra methods (maintenanceRefresh, tryClaimLightningReceive, offboardAll, peakKeyPair, verifyMessage, bolt11Invoice) and log config use - add Kotlin facade (NitroArkNative) and example RN module to surface these native calls - wire Android demo buttons in example app to exercise the JNI path with config passthrough and logging * Refactor NativeTypes and update JNI method signatures * Add null pointer checks in JNI helper functions * Add maintenance method to NitroArkNative * Refactor optional number retrieval in JNI wrapper * Add ARMv7 support to Android build script * Add Android JNI methods for signing and syncing * Improve memory management in NitroArkJni with local ref deletion * Refactor log formatting for birthday height in NitroArkJni * Add robust error handling for JNI string conversions * chore: bump version
1 parent 1980fb9 commit 286aaa0

File tree

13 files changed

+1246
-75
lines changed

13 files changed

+1246
-75
lines changed

.zed/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,14 @@
2424
"formatter": "language_server",
2525
"format_on_save": "on"
2626
}
27+
},
28+
"lsp": {
29+
"rust-analyzer": {
30+
"initialization_options": {
31+
"check": {
32+
"command": "clippy"
33+
}
34+
}
35+
}
2736
}
2837
}

bark-cpp/build-android.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ rm -rf "$OUTPUT_DIR"
7878

7979
# Create output directory structure
8080
mkdir -p "$OUTPUT_DIR/arm64-v8a"
81+
mkdir -p "$OUTPUT_DIR/armeabi-v7a"
8182
mkdir -p "$OUTPUT_DIR/x86_64"
8283

8384
echo "Building for Android..."
@@ -127,6 +128,30 @@ if [ -z "$ARM64_CXX_LIB_PATH" ]; then
127128
fi
128129
cp "$ARM64_CXX_LIB_PATH" "$OUTPUT_DIR/arm64-v8a/"
129130

131+
# --- Build for ARMv7 (armv7-linux-androideabi) ---
132+
echo "Building for armeabi-v7a..."
133+
TARGET_ARCH_ARMV7="armv7-linux-androideabi"
134+
TARGET_DIR_ARMV7="target/$TARGET_ARCH_ARMV7/$BUILD_TYPE"
135+
136+
export TARGET_AR="$TOOLCHAIN_PATH/bin/llvm-ar"
137+
export TARGET_CC="$TOOLCHAIN_PATH/bin/armv7a-linux-androideabi$API_LEVEL-clang"
138+
export TARGET_CXX="$TOOLCHAIN_PATH/bin/armv7a-linux-androideabi$API_LEVEL-clang++"
139+
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_AR="$TOOLCHAIN_PATH/bin/llvm-ar"
140+
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="$TOOLCHAIN_PATH/bin/armv7a-linux-androideabi$API_LEVEL-clang"
141+
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_RANLIB="$TOOLCHAIN_PATH/bin/llvm-ranlib"
142+
export OPENSSL_INCLUDE_DIR="$PWD/target/$TARGET_ARCH_ARMV7/$BUILD_TYPE/build/openssl-sys-*/out/include"
143+
export OPENSSL_LIB_DIR="$PWD/target/$TARGET_ARCH_ARMV7/$BUILD_TYPE/build/openssl-sys-*/out/lib"
144+
145+
rustup target add $TARGET_ARCH_ARMV7
146+
cargo build --target=$TARGET_ARCH_ARMV7 $CARGO_FLAG --lib
147+
cp "$TARGET_DIR_ARMV7/$BINARY_NAME" "$OUTPUT_DIR/armeabi-v7a/"
148+
ARMV7_CXX_LIB_PATH=$(find "$TARGET_DIR_ARMV7/build" -name "$CXX_BINARY_NAME" | head -n 1)
149+
if [ -z "$ARMV7_CXX_LIB_PATH" ]; then
150+
echo "Error: Could not find CXX bridge library for armeabi-v7a."
151+
exit 1
152+
fi
153+
cp "$ARMV7_CXX_LIB_PATH" "$OUTPUT_DIR/armeabi-v7a/"
154+
130155
# --- Build for x86_64 (x86_64-linux-android) ---
131156
echo "Building for x86_64..."
132157
TARGET_ARCH_X86_64="x86_64-linux-android"
@@ -153,15 +178,21 @@ cp "$X86_64_CXX_LIB_PATH" "$OUTPUT_DIR/x86_64/"
153178

154179
# --- Copy binaries to React Native project ---
155180
DEST_JNI_DIR_ARM64="../../react-native-nitro-ark/react-native-nitro-ark/android/src/main/jniLibs/arm64-v8a"
181+
DEST_JNI_DIR_ARMV7="../../react-native-nitro-ark/react-native-nitro-ark/android/src/main/jniLibs/armeabi-v7a"
156182
DEST_JNI_DIR_X86_64="../../react-native-nitro-ark/react-native-nitro-ark/android/src/main/jniLibs/x86_64"
157183

158184
mkdir -p "$DEST_JNI_DIR_ARM64"
185+
mkdir -p "$DEST_JNI_DIR_ARMV7"
159186
mkdir -p "$DEST_JNI_DIR_X86_64"
160187

161188
echo "Copying arm64-v8a binary..."
162189
cp -f "$OUTPUT_DIR/arm64-v8a/$BINARY_NAME" "$DEST_JNI_DIR_ARM64/"
163190
cp -f "$OUTPUT_DIR/arm64-v8a/$CXX_BINARY_NAME" "$DEST_JNI_DIR_ARM64/"
164191

192+
echo "Copying armeabi-v7a binary..."
193+
cp -f "$OUTPUT_DIR/armeabi-v7a/$BINARY_NAME" "$DEST_JNI_DIR_ARMV7/"
194+
cp -f "$OUTPUT_DIR/armeabi-v7a/$CXX_BINARY_NAME" "$DEST_JNI_DIR_ARMV7/"
195+
165196
echo "Copying x86_64 binary..."
166197
cp -f "$OUTPUT_DIR/x86_64/$BINARY_NAME" "$DEST_JNI_DIR_X86_64/"
167198
cp -f "$OUTPUT_DIR/x86_64/$CXX_BINARY_NAME" "$DEST_JNI_DIR_X86_64/"

react-native-nitro-ark/android/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ add_library(
2828
${PROJECT_NAME}
2929
SHARED
3030
src/main/cpp/cpp-adapter.cpp
31+
src/main/cpp/NitroArkJni.cpp
3132
../cpp/HybridArk.cpp
3233
)
3334

0 commit comments

Comments
 (0)