Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(example): add android:logs command #2050

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions example/android/scripts/logs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

PACKAGE_NAME=com.example

function monitor_logs {
echo "Monitoring logs for PID: $1"
adb logcat --pid="$1" &
LOGCAT_PID=$!

while adb shell "pidof -s $PACKAGE_NAME >/dev/null"; do
sleep 1
done

echo "Process $1 stopped. Killing logcat process..."
kill $LOGCAT_PID
}

while true; do
PID=$(adb shell pidof -s $PACKAGE_NAME)

if [ -n "$PID" ]; then
monitor_logs "$PID"
else
echo "$PACKAGE_NAME is not running. Waiting for process..."
sleep 1
fi
done
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"android:uninstall": "adb uninstall com.example",
"android:release": "cd android && ./gradlew clean && ./gradlew bundleRelease && cd app/build/outputs/bundle/release && pwd && ls",
"android:install-release": "RD=android/app/build/outputs/bundle/release && (rm $RD/app.apks || true) && bundletool build-apks --bundle=$RD/app-release.aab --output=$RD/app.apks && (adb uninstall com.example || true) && bundletool install-apks --apks=$RD/app.apks",
"android:logs": "android/scripts/logs",
"ios": "react-native run-ios",
"ios:ide": "open ios/*.xcworkspace/",
"windows": "react-native run-windows",
Expand Down