diff --git a/linux/lib.sh b/linux/lib.sh index 717f535..67c6d66 100755 --- a/linux/lib.sh +++ b/linux/lib.sh @@ -220,21 +220,55 @@ if [ ! -f "local.properties" ] && [ -z "$ANDROID_HOME" ]; then fi fi -if ! ./gradlew build; then +# Build the APK (assembleDebug creates the actual APK file) +# Suppress Java version warnings by setting gradle.properties +if [ ! -f "gradle.properties" ] || ! grep -q "android.javaCompile.suppressSourceTargetDeprecationWarning" gradle.properties 2>/dev/null; then + echo "" >> gradle.properties + echo "# Suppress Java version deprecation warnings" >> gradle.properties + echo "android.javaCompile.suppressSourceTargetDeprecationWarning=true" >> gradle.properties +fi + +if ! ./gradlew assembleDebug; then echo "" echo "Error: APK build failed" echo "Check the error messages above for details" exit 1 fi -APK_PATH="$SDK_DIR/FtcRobotController/build/outputs/apk/debug/FtcRobotController-debug.apk" -if [ ! -f "$APK_PATH" ]; then +# Find the APK - path varies by FTC SDK version +APK_PATH="" +for possible_path in \ + "$SDK_DIR/TeamCode/build/outputs/apk/debug/TeamCode-debug.apk" \ + "$SDK_DIR/FtcRobotController/build/outputs/apk/debug/FtcRobotController-debug.apk" \ + "$SDK_DIR/build/outputs/apk/debug/FtcRobotController-debug.apk" \ + "$SDK_DIR/FtcRobotController/build/outputs/apk/FtcRobotController-debug.apk"; do + if [ -f "$possible_path" ]; then + APK_PATH="$possible_path" + break + fi +done + +# If still not found, search for it +if [ -z "$APK_PATH" ]; then + APK_PATH=$(find "$SDK_DIR" -name "*-debug.apk" -type f 2>/dev/null | head -1) +fi + +if [ -z "$APK_PATH" ] || [ ! -f "$APK_PATH" ]; then + echo "" + echo "Error: APK not found after build" + echo "" + echo "Build succeeded but APK location is unexpected." + echo "Searched in:" + echo " • $SDK_DIR/TeamCode/build/outputs/apk/debug/" + echo " • $SDK_DIR/FtcRobotController/build/outputs/apk/debug/" + echo "" + echo "To find it manually:" + echo " find ~/ftc-sdk -name '*.apk' -type f" echo "" - echo "Error: APK not found at expected location" - echo "Expected: $APK_PATH" exit 1 fi -echo "✓ APK built" + +echo "✓ APK built at: $(basename "$APK_PATH")" echo "" # Step 3: Install to Control Hub