Files
self/packages/mobile-sdk-alpha/scripts/build-android.sh
Justin Hernandez 077dcc47b4 [SELF-830] feat: demo app nfc scanning (#1236)
* save wip demo app nfc scanning

* save wip

* fix types

* Fix Android NFC scanning in demo app (#1241)

* fix tests

* fix pipelines

* fix linting

* WIP move to flows/onboarding/scan-nfc

* prettier and fix test

* fix test

* update lock

* update deps

* Feat/android prebuilt modules (#1292)

* move entire screen

* remove redundancy in components and utils

* fixes

* lint

* ignore

* remove unneeded

* fix imports

* remove unused

* Update packages/mobile-sdk-alpha/src/types/events.ts

Co-authored-by: Aaron DeRuvo <aaron.deruvo@clabs.co>

* uuid not needed for demo app

* android: update ci check

* timeout fix, image temp fix

* prettier fix

* try rebuild deps every time

* Temporarily disable cache check in CI

* Revert "try rebuild deps every time"

This reverts commit a5c97210a5.

* ignore false positive

* Revert "Revert "try rebuild deps every time""

This reverts commit 4f44615fd6.

* fix?

* sanitize error message first

* remove TODO that has been taken care of

* MSDK: add ios prebuilts (#1308)

* add ios prebuilt

* remove outdate readme

* remove duplicates

* comment out unused

* add prettier ignore

* Update .gitguardian.yml to ignore iOS frameworks and build artifacts

* update gitguardian ignore paths

* migrate config version

* add ignored-matches

---------

Co-authored-by: Justin Hernandez <justin.hernandez@self.xyz>

* remove duplicated code

* exclude mobile-sdk native modules when `E2E_TESTING` flag is set

* app: disable ios msdk auto-linking

* add E2E_TESTING flag

---------

Co-authored-by: Leszek Stachowski <leszek.stachowski@self.xyz>
Co-authored-by: seshanthS <seshanth@protonmail.com>
Co-authored-by: Seshanth.S <35675963+seshanthS@users.noreply.github.com>
Co-authored-by: Aaron DeRuvo <aaron.deruvo@clabs.co>
2025-10-23 23:14:32 +05:30

90 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
# SPDX-License-Identifier: BUSL-1.1
# NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
# Build Android AAR from source using the app's Gradle wrapper
set -e
echo "🤖 Building Android AAR for mobile-sdk-alpha..."
# Navigate to SDK directory
SDK_DIR="$(dirname "$0")/.."
cd "$SDK_DIR"
# Ensure dist/android directory exists
mkdir -p dist/android
# Check if native modules source is available
MOBILE_SDK_NATIVE="mobile-sdk-native"
echo "🔍 Checking for Android build options..."
if [ -d "$MOBILE_SDK_NATIVE" ]; then
echo "✅ Native modules source submodule found, building from source..."
# Check if we already have an AAR file
if [ -f "dist/android/mobile-sdk-alpha-release.aar" ]; then
echo "✅ AAR file found, skipping build"
echo "📦 Using existing AAR: dist/android/mobile-sdk-alpha-release.aar"
exit 0
fi
# Update submodule to latest
echo "🔄 Updating submodule to latest..."
git submodule update --init --recursive mobile-sdk-native
# Navigate to android directory
cd android
# Check if we're in a monorepo and can use the app's gradlew
APP_GRADLEW="../../../app/android/gradlew"
if [ -f "$APP_GRADLEW" ]; then
echo "✅ Using app's Gradle wrapper"
# Copy source from submodule if available
if [ -d "../$MOBILE_SDK_NATIVE/src" ]; then
echo "📝 Copying source from submodule to android directory..."
rm -rf src
cp -r "../$MOBILE_SDK_NATIVE/src" .
fi
if [ -d "../$MOBILE_SDK_NATIVE/libs" ]; then
echo "📝 Copying libs from submodule to android directory..."
rm -rf libs
cp -r "../$MOBILE_SDK_NATIVE/libs" .
fi
# Build using app's gradlew from the app's android directory
# This ensures React Native and other dependencies are available
cd ../../../app/android
./gradlew :mobile-sdk-alpha:assembleRelease
echo "✅ Android AAR built successfully from submodule source"
echo "📦 AAR location: packages/mobile-sdk-alpha/dist/android/"
echo "💡 Changes in mobile-sdk-native/ are tracked with git history"
else
echo "❌ Error: Could not find app's Gradle wrapper at $APP_GRADLEW"
echo "Please ensure you're running this from the monorepo root or that the app is set up."
exit 1
fi
else
echo "⚠️ Private source not found, checking for prebuilt AAR..."
# Check if prebuilt AAR already exists
if [ -f "dist/android/mobile-sdk-alpha-release.aar" ]; then
echo "✅ Prebuilt AAR found: dist/android/mobile-sdk-alpha-release.aar"
echo "📦 Using existing prebuilt AAR"
else
echo "❌ No prebuilt AAR found at dist/android/mobile-sdk-alpha-release.aar"
echo "💡 To build from source, clone the mobile-sdk-native repository:"
echo " node scripts/setup-native-source.cjs"
echo " yarn build:android"
echo ""
echo "⚠️ Package may not work without AAR file!"
exit 1
fi
fi