This guide explains how to use the unified demo.sh script to build your Flutter application for all platforms with automatic Sentry release management and instrumentation.
# Verify setup
./demo.sh verify
# Build for Android APK
./demo.sh build android
# Build for Android App Bundle (preferred)
./demo.sh build aab
# Build for iOS
./demo.sh build ios
# Build for Web
./demo.sh build web
# Run the app
./demo.sh run android./demo.sh build [platform] [build-type]
./demo.sh run [platform]
./demo.sh verify| Platform | Command | OS Requirement | Output Location |
|---|---|---|---|
| Android APK | ./demo.sh build android |
Any | build/app/outputs/flutter-apk/app-release.apk |
| Android AAB | ./demo.sh build aab |
Any | build/app/outputs/bundle/release/app-release.aab |
| iOS | ./demo.sh build ios |
macOS only | build/ios/iphoneos/Runner.app |
| Web | ./demo.sh build web |
Any | build/web/ |
| macOS | ./demo.sh build macos |
macOS only | build/macos/Build/Products/Release/empower_flutter.app |
| Linux | ./demo.sh build linux |
Linux preferred | build/linux/x64/release/bundle/ |
| Windows | ./demo.sh build windows |
Windows only | build/windows/x64/runner/Release/ |
| Type | Command | Description | Obfuscation | Release Management |
|---|---|---|---|---|
| Release | ./demo.sh build android |
Production build | ✅ Yes | ✅ Yes |
| Profile | ./demo.sh build android profile |
Performance profiling | ❌ No | ❌ No |
| Debug | ./demo.sh build android debug |
Development build | ❌ No | ❌ No |
Default: Release build with obfuscation, symbol upload, and automatic release management
- Checks for Flutter installation
- Loads environment variables from
.envfile - Validates platform compatibility
- Runs
flutter pub getto ensure all dependencies are up to date
- Executes platform-specific build command
- For release builds:
- Enables code obfuscation (
--obfuscate) - Generates debug symbols (
--split-debug-info) - Includes Sentry environment variables
- Enables code obfuscation (
- For debug/profile builds:
- Standard build without obfuscation
- Automatically uploads debug symbols to Sentry
- Uploads source maps (for web)
- Associates symbols with release version
- Optional: Uploads builds for size analysis (when enabled)
# Debug build for testing
./demo.sh build android debug
# Release build for distribution
./demo.sh build android releaseAfter building, install on emulator:
# Find the APK
find . -name '*.apk'
# Drag and drop to emulator, or use adb:
adb install build/app/outputs/flutter-apk/app-release.apk# Debug build
./demo.sh build ios debug
# Release build
./demo.sh build ios releaseThen open in Xcode:
open ios/Runner.xcworkspace# Build for web
./demo.sh build web release
# Serve locally for testing
cd build/web
python3 -m http.server 8000Open browser to http://localhost:8000
# Build macOS app
./demo.sh build macos releaseRun the app:
open build/macos/Build/Products/Release/empower_flutter.app# Build everything available on your OS
./demo.sh build all releaseOn macOS: Builds Android, iOS, Web, and macOS On Linux: Builds Android, Web, and Linux On Windows: Builds Android, Web, and Windows
The script automatically uploads symbols for release builds if Sentry is configured.
Add to your .env file:
SENTRY_DSN=https://your-key@o0.ingest.sentry.io/0000000
SENTRY_RELEASE=myapp@9.14.0+2
SENTRY_ENVIRONMENT=productionCreate sentry.properties:
org=your-org-slug
project=your-project-name
auth_token=your-sentry-auth-token- Visit: https://sentry.io/settings/account/api/auth-tokens/
- Click "Create New Token"
- Name: "Flutter Debug Symbol Upload"
- Scopes:
project:releases(orproject:write) andorg:read - Copy the token to
sentry.properties
Monitor your app's build sizes to prevent regressions and optimize downloads.
Prerequisites:
- Install Sentry CLI:
curl -sL https://sentry.io/get-cli/ | bash - Configure Sentry auth token (see above)
Configuration:
Add to your .env file:
SENTRY_SIZE_ANALYSIS_ENABLED=true
SENTRY_ORG=your-org-slug
SENTRY_PROJECT=your-project-slugUsage:
# Build with size analysis
./demo.sh build android releaseThe script will automatically:
- Build your app
- Upload debug symbols
- Upload build for size analysis
Output:
✓ Android APK built successfully
ℹ APK location: build/app/outputs/flutter-apk/app-release.apk
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Uploading Android Build for Size Analysis
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ Size analysis data uploaded successfully
ℹ View results: https://sentry.io/organizations/your-org/projects/your-project/size-analysis/
Supported Platforms:
- ✅ Android - APK/AAB automatic upload
⚠️ iOS - Requires manual IPA creation and upload (see SIZE_ANALYSIS_GUIDE.md)
For detailed instructions and CI/CD integration, see the Size Analysis Guide.
✗ Flutter is not installed or not in PATH
Solution: Install Flutter or add to PATH:
export PATH="$PATH:/path/to/flutter/bin"✗ iOS builds require macOS
Solution: iOS and macOS builds can only be performed on macOS systems.
✗ Failed to upload debug symbols
Solutions:
- Check
sentry.propertiesconfiguration - Verify auth token has correct scopes
- Ensure
SENTRY_DSNis set in.env - Check network connectivity
Error: Package not found
Solution:
flutter pub get
flutter clean
./demo.sh build android- Dependency installation
- Environment variable loading
- Platform compatibility checking
- Colored output for easy reading
- Error handling and validation
- Build location reporting
- Code obfuscation
- Debug symbol generation
- Sentry symbol upload
- Source map generation (web)
- Release version tagging
- Cross-platform compatible
- Platform-specific optimizations
- Intelligent fallback handling
- OS detection and validation
Edit run.sh to add custom flags:
# Example: Add custom build name
flutter build android \
--$BUILD_TYPE \
--build-name=2.0.0 \
--build-number=42 \
--obfuscate \
--split-debug-info=$DEBUG_INFO_PATHAvailable environment variables:
SENTRY_DSN- Sentry Data Source NameSENTRY_RELEASE- Release versionSENTRY_ENVIRONMENT- Environment (production, staging, etc.)
Use in CI/CD pipelines:
# GitHub Actions example
- name: Build Android Release
run: ./demo.sh build android release
env:
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_RELEASE: ${{ github.ref_name }}
SENTRY_ENVIRONMENT: production- Use
debugbuilds during development - Use
profilebuilds for performance testing - Use
releasebuilds for distribution only
Clean build artifacts periodically:
flutter clean
rm -rf build/
./demo.sh build androidOn multi-core systems, Flutter automatically uses parallel builds. For faster builds:
# Clear cache and rebuild
flutter clean
flutter pub get
./demo.sh build allThe enhanced run.sh script provides a unified, automated build system for Flutter applications with full Sentry integration. It handles all platform-specific configurations, symbol uploads, and build optimizations automatically.
For questions or issues, refer to:
- Flutter Documentation
- Sentry Flutter Documentation
- Project README.md