The app was throwing a FileNotFoundException when trying to read masters_asset.pem:
Error reading ICAO
java.io.FileNotFoundException: masters_asset.pem
at android.content.res.AssetManager.open(...)
at com.rarilabs.rarime.manager.ProofGenerationManager.readICAO(ProofGenerationManager.kt:868)
- Missing Assets Directory: The
app/src/main/assets/directory did not exist in the project. - Missing Certificate File: The
masters_asset.pemfile was not present in the assets folder. - Suboptimal Context Usage: The code was using
createPackageContext()unnecessarily, which could cause issues in some scenarios.
- Created
app/src/main/assets/directory structure
- Created
app/src/main/assets/masters_asset.pemas a placeholder - IMPORTANT: This is a placeholder file. You must replace it with the actual ICAO master certificate PEM file.
- Updated
readICAO()method inProofGenerationManager.kt:- Simplified context usage (removed unnecessary
createPackageContext()) - Added proper error handling with specific
FileNotFoundExceptioncatch - Added validation for empty file
- Added debug logging for successful file loading
- Improved error messages to guide developers
- Simplified context usage (removed unnecessary
- Added
import java.io.FileNotFoundExceptionto handle the specific exception type
-
app/src/main/assets/masters_asset.pem (NEW)
- Placeholder PEM certificate file
- Location:
app/src/main/assets/masters_asset.pem
-
app/src/main/java/com/rarilabs/rarime/manager/ProofGenerationManager.kt
- Updated
readICAO()method (lines 865-890) - Added
FileNotFoundExceptionimport
- Updated
- Obtain the actual ICAO master certificate PEM file from your project administrator or ICAO authority
- Replace
app/src/main/assets/masters_asset.pemwith the real certificate file - Ensure the file is a valid PEM format certificate
- The file should contain the ICAO master certificate used for passport certificate validation
- Missing Directory Structure: Android assets must be in
app/src/main/assets/directory, which didn't exist - Missing File: The certificate file was never added to the project
- Build System: Android's build system automatically includes files from the
assets/directory, but only if the directory exists
- Directory Created: The assets directory now exists, so Android's build system will include it
- File Present: The placeholder file ensures the code won't crash, but you must replace it with the real certificate
- Better Error Handling: Improved error messages will help identify issues if the file is missing or invalid
- Simplified Context: Using
applicationContextdirectly is more reliable thancreatePackageContext()
After replacing the placeholder with the real certificate:
- Clean and rebuild the project
- Test the registration flow
- Verify that
readICAO()successfully loads the certificate - Check logs for "Successfully loaded ICAO master certificate" message
No changes to build.gradle.kts were needed. Android automatically includes files from app/src/main/assets/ in the APK/AAB during the build process.