#!/bin/bash # Build script for Android Health Analytics C++ library # Set paths to your Android NDK and CMake tools NDK_PATH="/home/charlotte/Android/Sdk/ndk/29.0.13113456" CMAKE_PATH="/home/charlotte/Android/Sdk/cmake/3.22.1/bin/cmake" NINJA_PATH="/home/charlotte/Android/Sdk/cmake/3.22.1/bin/ninja" # Define the build directory (here for arm64-v8a) BUILD_DIR="build/android/arm64-v8a" # Remove previous build directory if it exists rm -rf "$BUILD_DIR" mkdir -p "$BUILD_DIR" # Configure the project using CMake with Android toolchain "$CMAKE_PATH" \ -H. \ -B"$BUILD_DIR" \ -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DANDROID_ABI=arm64-v8a \ -DANDROID_PLATFORM=android-21 \ -DANDROID_NDK="$NDK_PATH" \ -DCMAKE_TOOLCHAIN_FILE="$NDK_PATH/build/cmake/android.toolchain.cmake" \ -DCMAKE_MAKE_PROGRAM="$NINJA_PATH" \ -DANDROID_STL=c++_shared # Build the target library "$CMAKE_PATH" --build "$BUILD_DIR" --target statistics # Create necessary directories for copying the library mkdir -p "$BUILD_DIR/lib" # Copy the library from the correct location cp "$BUILD_DIR/linux/libstatistics.so" "$BUILD_DIR/lib/" cp "$BUILD_DIR/linux/libstatistics.so" ./ # Check if the build was successful if [ $? -eq 0 ]; then echo "Health Analytics C++ library built successfully for Android!" else echo "Android build failed." fi