feat: Add automatic Android asset validation to prevent build failures
- Add validate_android_assets() function to build-android.sh - Check for missing source assets (icon.png, splash.png, splash_dark.png) - Verify Android resources exist (drawable/splash.png, mipmap/*/ic_launcher*.png) - Auto-regenerate missing resources using @capacitor/assets - Integrate validation into main build process with exit code 9 - Add npm run assets:validate:android for manual validation - Support --assets-only flag for asset-only operations - Create comprehensive documentation in doc/android-asset-validation.md Fixes build failures caused by missing drawable/splash and mipmap/ic_launcher resources. Prevents "Android resource linking failed" errors during Gradle builds. Resolves: Android build failures due to missing asset resources
This commit is contained in:
67
BUILDING.md
67
BUILDING.md
@@ -164,6 +164,9 @@ npm run clean:android
|
||||
npm run build:ios # Regenerates iOS project
|
||||
npm run build:android # Regenerates Android project
|
||||
|
||||
# Fix Android asset issues
|
||||
npm run assets:validate:android # Validates and regenerates missing Android assets
|
||||
|
||||
# Check environment
|
||||
npm run test:web # Verifies web setup
|
||||
```
|
||||
@@ -172,6 +175,7 @@ npm run test:web # Verifies web setup
|
||||
|
||||
- **iOS**: Ensure Xcode and Command Line Tools are installed
|
||||
- **Android**: Ensure Android Studio and SDK are configured
|
||||
- If you encounter "resource drawable/splash not found" errors, run `npm run assets:validate:android`
|
||||
- **Electron**: Ensure platform-specific build tools are installed
|
||||
|
||||
### Next Steps
|
||||
@@ -1184,6 +1188,69 @@ npm run build:android:assets # Generate assets only
|
||||
npm run build:android:deploy # Build and deploy to connected device
|
||||
```
|
||||
|
||||
#### Android Asset Validation
|
||||
|
||||
The Android build system now includes automatic asset validation to prevent build failures caused by missing resources. This system:
|
||||
|
||||
- **Validates Source Assets**: Checks that required source files exist in `resources/`
|
||||
- **Checks Android Resources**: Verifies that generated Android resources are present
|
||||
- **Auto-Regenerates**: Automatically regenerates missing resources when detected
|
||||
- **Provides Clear Errors**: Gives helpful guidance when issues occur
|
||||
|
||||
##### Asset Validation Commands
|
||||
|
||||
```bash
|
||||
# Validate and regenerate Android assets if needed
|
||||
npm run assets:validate:android
|
||||
|
||||
# Alternative command for asset validation
|
||||
./scripts/build-android.sh --assets-only
|
||||
|
||||
# Check asset configuration only (no regeneration)
|
||||
npm run assets:validate
|
||||
```
|
||||
|
||||
##### What Gets Validated
|
||||
|
||||
**Source Assets (Required):**
|
||||
- `resources/icon.png` - App icon source
|
||||
- `resources/splash.png` - Splash screen source
|
||||
- `resources/splash_dark.png` - Dark mode splash source
|
||||
|
||||
**Android Resources (Generated):**
|
||||
- `android/app/src/main/res/drawable/splash.png` - Splash screen drawable
|
||||
- `android/app/src/main/res/mipmap-*/ic_launcher.png` - App icons for all densities
|
||||
- `android/app/src/main/res/mipmap-*/ic_launcher_round.png` - Round app icons for all densities
|
||||
|
||||
##### Automatic Validation
|
||||
|
||||
Asset validation runs automatically during all Android builds:
|
||||
|
||||
```bash
|
||||
# All these commands now include asset validation
|
||||
npm run build:android:studio
|
||||
npm run build:android:prod
|
||||
npm run build:android:debug
|
||||
```
|
||||
|
||||
If validation fails, the build stops with clear error messages and guidance on how to fix the issues.
|
||||
|
||||
##### Troubleshooting Asset Issues
|
||||
|
||||
If you encounter asset-related build failures:
|
||||
|
||||
```bash
|
||||
# Check what's missing
|
||||
npm run assets:validate:android
|
||||
|
||||
# Clean and regenerate everything
|
||||
npm run clean:android
|
||||
npm run assets:validate:android
|
||||
npm run build:android:studio
|
||||
```
|
||||
|
||||
For more detailed information, see [Android Asset Validation Documentation](doc/android-asset-validation.md).
|
||||
|
||||
#### Android Automated Build Script
|
||||
|
||||
The recommended way to build for Android is using the automated build script:
|
||||
|
||||
Reference in New Issue
Block a user