79 lines
1.8 KiB
Bash
Raw Normal View History

#!/bin/bash
# Android Chat Client Build Script
set -e
echo "================================"
echo "SCAR Chat Android Client Builder"
echo "================================"
echo ""
# Check if we're in the right directory
if [ ! -f "settings.gradle" ]; then
echo "Error: settings.gradle not found!"
echo "Please run this script from the android_client directory:"
echo " cd android_client"
echo " ./build.sh"
exit 1
fi
# Check for Java
if ! command -v java &> /dev/null; then
echo "Error: Java not found in PATH"
echo "Please install Java JDK 11 or later"
echo "Linux: sudo apt-get install openjdk-11-jdk"
echo "macOS: brew install java@11"
echo "Windows: https://adoptopenjdk.net/"
exit 1
fi
JAVA_VERSION=$(java -version 2>&1 | head -1)
echo "✓ Java found: $JAVA_VERSION"
echo ""
# Check for Android SDK
if [ -z "$ANDROID_HOME" ]; then
echo "Warning: ANDROID_HOME not set"
echo "Attempting to find Android SDK..."
if [ -d "$HOME/Android/Sdk" ]; then
export ANDROID_HOME="$HOME/Android/Sdk"
echo "✓ Found Android SDK at: $ANDROID_HOME"
else
echo "Error: Android SDK not found!"
echo "Please install Android Studio or Android SDK"
echo "Set ANDROID_HOME environment variable to SDK location"
exit 1
fi
fi
echo ""
echo "Building Android Chat Client..."
echo ""
# Make gradlew executable
chmod +x ./gradlew
# Run build
./gradlew build
BUILD_RESULT=$?
if [ $BUILD_RESULT -eq 0 ]; then
echo ""
echo "✓ Build successful!"
echo ""
echo "Output APKs:"
echo " Debug: app/build/outputs/apk/debug/app-debug.apk"
echo " Release: app/build/outputs/apk/release/app-release.apk"
echo ""
echo "To install on device:"
echo " ./gradlew installDebug"
echo ""
else
echo ""
echo "✗ Build failed!"
exit 1
fi