-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Okay, here's a summary of the issue and the debugging process in English, suitable for a GitHub PR or issue description:
Issue Summary:
The application crashes with a java.lang.SecurityException: Unknown calling package name 'com.google.android.gms'. error originating from GoogleApiManager shortly after navigating to the HomeScreen (post-login). This occurs despite the primary user-facing Firebase features (like Auth and manual Firestore checks) appearing functional.
Debugging Steps & Findings:
- Initial Checks: Verified that the
applicationId(com.nguyenmoclam.InsightTube) inapp/build.gradle.ktsmatches thepackage_nameingoogle-services.json. - SHA-1 Verification: Confirmed that the debug SHA-1 fingerprint obtained via
./gradlew signingReportmatches thecertificate_hashingoogle-services.json. - Code Review:
- Analyzed
MainActivity,YouTubeSummaryApplication,HomeScreen, andHomeViewModel. - Investigated
QuizRepositoryImpl, which is used byHomeViewModelto fetch data forHomeScreen. Crucially, found thatQuizRepositoryImplinteracts with a local Room/SQLite database, not Firebase Firestore, for quizzes, tags, progress, etc. This rules out direct Firestore queries from this repository as the cause of the GMS error. - Reviewed
ModelDataRefreshWorker, found it interacts withOpenRouterRepositoryand is unlikely to cause this specific GMSSecurityException.
- Analyzed
- Logcat Analysis:
- The primary error is
GoogleApiManager E Failed to get service from broker.followed by theSecurityException. - Key Finding: Immediately following the
SecurityException, there are critical errors related to Google Play Services core functionality:CondFlagRegistrar W Failed to register com.google.android.gms.providerinstaller#com.google.android.gmseuda: 17: 17: API: Phenotype.API is not available on this device. Connection failed with: ConnectionResult{statusCode=DEVELOPER_ERROR, ...}
- The primary error is
- GMS Version: Checked Google Play Services version on the device (
adb shell dumpsys package com.google.android.gms | grep versionName), found25.16.33, which seems reasonably up-to-date.
Conclusion:
Despite correct configuration files (google-services.json, build.gradle.kts) and matching SHA-1, the application fails to properly interact with core Google Play Services components after login. The error Phenotype.API is not available on this device with statusCode=DEVELOPER_ERROR strongly indicates an issue with the Google Play Services environment itself on the specific emulator/device being used. GMS is likely in a faulty or incompatible state, preventing it from correctly serving the app, even if its version number appears current and some high-level Firebase features seem functional momentarily.
Recommendation:
The most probable cause is the specific Android environment. The primary recommendation is to test the exact same codebase on a different, clean Android environment (e.g., another physical device or a standard AVD with Google Play). If the issue is resolved there, the original environment needs troubleshooting (Wipe Data, Clear GMS Cache/Data). If the issue persists even on clean environments, further investigation into implicit GMS dependencies or potential SDK interactions would be required, although this is less likely given the specific Phenotype.API error. Ignoring the error is not advised due to potential instability and hidden issues.