From 91c374756b8e42438900df3d0c9e20d3b14bbde0 Mon Sep 17 00:00:00 2001 From: devthejo Date: Thu, 1 May 2025 17:18:17 +0200 Subject: [PATCH] chore: fix install-android --- docs/android-install.md | 99 +++++++++++++++++++++++++++++++++++++++++ install-android.sh | 30 +++++++++++++ package.json | 4 +- 3 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 docs/android-install.md create mode 100755 install-android.sh diff --git a/docs/android-install.md b/docs/android-install.md new file mode 100644 index 0000000..34dcae9 --- /dev/null +++ b/docs/android-install.md @@ -0,0 +1,99 @@ +# Android App Installation Guide + +This guide explains how to install the Android app on an emulator or physical device. + +## Prerequisites + +- Android emulator or physical device connected via ADB +- Java installed (for bundletool) +- ADB installed and configured + +## Installation + +### Using the Yarn Script + +The easiest way to install the app is to use the provided yarn script: + +```bash +# Set the device ID (emulator or physical device) +export DEVICE=emulator-5554 + +# Run the installation script +yarn install:android +``` + +### Manual Installation + +If you need to install the app manually, follow these steps: + +1. Navigate to the bundle release directory: + ```bash + cd android/app/build/outputs/bundle/release + ``` + +2. Build APKs with signing: + ```bash + java -jar /opt/bundletool-all-1.17.1.jar build-apks \ + --mode universal \ + --bundle ./app-release.aab \ + --output ./app.apks \ + --ks /home/jo/lab/alerte-secours/as-app/android/app/debug.keystore \ + --ks-pass pass:android \ + --ks-key-alias androiddebugkey \ + --key-pass pass:android + ``` + +3. Convert .apks to .zip and extract: + ```bash + mv app.apks app.zip + unzip -o app.zip + ``` + +4. Install the APK on the device: + ```bash + adb -s $DEVICE install universal.apk + ``` + +## Troubleshooting + +### Finding Available Devices + +To list all available devices: + +```bash +adb devices +``` + +Example output: +``` +List of devices attached +emulator-5554 device +``` + +### Common Issues + +1. **No devices found**: Make sure your emulator is running or your physical device is connected and has USB debugging enabled. + +2. **Installation fails**: Check if the app is already installed. You might need to uninstall it first: + ```bash + adb -s $DEVICE uninstall com.alertesecours + ``` + +3. **Signing issues**: If you encounter signing problems, make sure the keystore path is correct and the keystore passwords match. + +## Custom Installation Script + +A custom installation script (`install-android.sh`) has been created to simplify the installation process. This script: + +1. Checks if the DEVICE environment variable is set +2. Navigates to the bundle release directory +3. Builds APKs with signing +4. Converts .apks to .zip and extracts it +5. Installs the APK on the device + +You can run this script directly: + +```bash +export DEVICE=emulator-5554 +./install-android.sh +``` diff --git a/install-android.sh b/install-android.sh new file mode 100755 index 0000000..3114f7f --- /dev/null +++ b/install-android.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Check if DEVICE environment variable is set +if [ -z "$DEVICE" ]; then + echo "Error: DEVICE environment variable is not set." + echo "Usage: DEVICE=emulator-5554 ./install-android.sh" + exit 1 +fi + +# Navigate to the bundle release directory +cd android/app/build/outputs/bundle/release + +# Build APKs with signing +java -jar /opt/bundletool-all-1.17.1.jar build-apks \ + --mode universal \ + --bundle ./app-release.aab \ + --output ./app.apks \ + --ks $HOME/lab/alerte-secours/as-app/android/app/debug.keystore \ + --ks-pass pass:android \ + --ks-key-alias androiddebugkey \ + --key-pass pass:android + +# Convert .apks to .zip and extract +mv app.apks app.zip +unzip -o app.zip + +# Install the APK on the device +adb -s $DEVICE install universal.apk + +echo "Installation complete!" diff --git a/package.json b/package.json index 0bcc63c..1e4bab1 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "e2e:start": "adb -s emulator-5554 shell am start -n com.alertesecours/.MainActivity", "e2e:test": "detox test --configuration android.emu.debug", "e2e:run": "yarn start & yarn e2e:build && yarn e2e:deploy && yarn e2e:test", - "install:android": "cd android/app/build/outputs/bundle/release && java -jar /opt/bundletool-all-1.17.1.jar build-apks --mode universal --bundle ./app-release.aab --output ./app.apks && mv app.apks app.zip && unzip -o app.zip && adb -s $DEVICE install universal.apk", + "install:android": "./install-android.sh", "log:android": "adb -s $DEVICE logcat | grep -E 'ReactNativeJS: '", "log:ios:simulator": "xcrun simctl spawn booted log stream --level debug --predicate 'subsystem contains \"com.facebook.react.log\" and processImagePath contains \"AlerteSecours\"'", "log:ios": "idevicesyslog | grep -i 'AlerteSecours\\|ReactNative'", @@ -276,4 +276,4 @@ } }, "packageManager": "yarn@4.5.3" -} \ No newline at end of file +}