-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-android-studio-macos.sh
More file actions
executable file
·97 lines (84 loc) · 2.95 KB
/
setup-android-studio-macos.sh
File metadata and controls
executable file
·97 lines (84 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Setup Android Studio path for macOS
# This script helps configure the Android Studio path for Capacitor on macOS
# Detect OS
OS="$(uname -s)"
case "${OS}" in
Linux*) MACHINE=Linux;;
Darwin*) MACHINE=macOS;;
CYGWIN*) MACHINE=Cygwin;;
MINGW*) MACHINE=MinGW;;
*) MACHINE="UNKNOWN:${OS}"
esac
echo "🔧 Setting up Android Studio path..."
if [ "$MACHINE" != "macOS" ]; then
echo "⚠️ Warning: This script is designed for macOS"
echo " Current OS: $MACHINE"
echo ""
echo "📝 Instructions for macOS:"
echo " 1. Run this script on your macOS machine"
echo " 2. Or manually set the environment variable:"
echo ""
echo " export CAPACITOR_ANDROID_STUDIO_PATH=\"/Applications/Android Studio.app/Contents/MacOS/studio\""
echo ""
echo " 3. Add to ~/.zshrc or ~/.bash_profile for permanent setup:"
echo " echo 'export CAPACITOR_ANDROID_STUDIO_PATH=\"/Applications/Android Studio.app/Contents/MacOS/studio\"' >> ~/.zshrc"
echo " source ~/.zshrc"
echo ""
echo " 4. Then run 'npm run android:open' on your macOS machine"
exit 0
fi
echo "✅ Detected macOS"
# Default macOS Android Studio path
DEFAULT_PATH="/Applications/Android Studio.app/Contents/MacOS/studio"
# Check if Android Studio exists at default location
if [ -f "$DEFAULT_PATH" ]; then
echo "✅ Found Android Studio at: $DEFAULT_PATH"
STUDIO_PATH="$DEFAULT_PATH"
else
echo "⚠️ Android Studio not found at default location"
echo "Please enter the path to Android Studio executable:"
echo " (Usually: /Applications/Android Studio.app/Contents/MacOS/studio)"
read -p "Path: " STUDIO_PATH
if [ ! -f "$STUDIO_PATH" ]; then
echo "❌ Error: File not found at: $STUDIO_PATH"
exit 1
fi
fi
# Detect shell
if [ -n "$ZSH_VERSION" ]; then
SHELL_RC="$HOME/.zshrc"
elif [ -n "$BASH_VERSION" ]; then
SHELL_RC="$HOME/.bash_profile"
if [ ! -f "$SHELL_RC" ]; then
SHELL_RC="$HOME/.bashrc"
fi
else
SHELL_RC="$HOME/.profile"
fi
# Check if already set
if grep -q "CAPACITOR_ANDROID_STUDIO_PATH" "$SHELL_RC" 2>/dev/null; then
echo "⚠️ CAPACITOR_ANDROID_STUDIO_PATH already set in $SHELL_RC"
read -p "Update it? (y/n): " UPDATE
if [ "$UPDATE" = "y" ] || [ "$UPDATE" = "Y" ]; then
# Remove old entry
sed -i.bak "/CAPACITOR_ANDROID_STUDIO_PATH/d" "$SHELL_RC"
echo "✅ Removed old entry"
else
echo "Keeping existing configuration"
exit 0
fi
fi
# Add to shell RC
echo "" >> "$SHELL_RC"
echo "# Capacitor Android Studio Path (added by setup script)" >> "$SHELL_RC"
echo "export CAPACITOR_ANDROID_STUDIO_PATH=\"$STUDIO_PATH\"" >> "$SHELL_RC"
echo "✅ Added to $SHELL_RC"
echo ""
echo "To apply immediately, run:"
echo " export CAPACITOR_ANDROID_STUDIO_PATH=\"$STUDIO_PATH\""
echo ""
echo "Or restart your terminal/shell"
echo ""
echo "You can now run:"
echo " npm run android:open"