33 lines
957 B
Bash
33 lines
957 B
Bash
#!/bin/bash
|
|
# Fix Flutter Android build: AGP 8.x namespace issue with old device_info package
|
|
# Run AFTER: flutter create --project-name voidea_app --org com.voidea .
|
|
# Usage: bash fix_build.sh
|
|
|
|
set -e
|
|
|
|
PUB_CACHE="${FLUTTER_ROOT:-$HOME/flutter}/.pub-cache/hosted/pub.dev"
|
|
|
|
echo "Fixing device_info namespace for AGP 8+..."
|
|
|
|
DEVICE_INFO_DIR=$(ls -d "$PUB_CACHE"/device_info-* 2>/dev/null | sort -V | tail -1)
|
|
|
|
if [ -z "$DEVICE_INFO_DIR" ]; then
|
|
echo "device_info not found in pub cache. Run flutter pub get first."
|
|
exit 1
|
|
fi
|
|
|
|
BUILD_GRADLE="$DEVICE_INFO_DIR/android/build.gradle"
|
|
if [ ! -f "$BUILD_GRADLE" ]; then
|
|
echo "build.gradle not found at $BUILD_GRADLE"
|
|
exit 1
|
|
fi
|
|
|
|
if grep -q "namespace " "$BUILD_GRADLE"; then
|
|
echo "namespace already set in $BUILD_GRADLE"
|
|
else
|
|
sed -i 's/android {/android {\n namespace "com.voidea.app"/' "$BUILD_GRADLE"
|
|
echo "Patched namespace in $BUILD_GRADLE"
|
|
fi
|
|
|
|
echo "Done. Run 'flutter run' now."
|