android – INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION – Stack Overflow

I am having problem installing an Android using Android. The build finishes successfully, but the installation fails with INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION.

Most of the solutions I found online asks to change package name to all lower case, but my package name IS lower case. I have been poking around here and there, but I am not too familiar with Android development, so no luck.

4: Run output

02/21 17:23:17: Launching 'app' on Pixel 4 API 30.
Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION

List of apks:
(0) '/Users/myusername/Repositories/FedML-Mobile/android/app/build/outputs/apk/debug/app-debug.apk'
Installation failed due to: 'null'
Retry

6: Logcat output

2021-02-21 17:25:09.752 373-373/? W/adbd: timeout expired while flushing socket, closing
2021-02-21 17:25:12.732 373-373/? W/adbd: timeout expired while flushing socket, closing
2021-02-21 17:25:15.371 457-457/? E/netmgr: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:network' service: Invalid argument
2021-02-21 17:25:15.371 457-457/? E/netmgr: Failed to open QEMU pipe 'qemud:network': Invalid argument
2021-02-21 17:25:15.653 494-823/? W/ActivityManager: Invalid packageName: ai.fedml.android
2021-02-21 17:25:15.655 15149-15151/? I/cmd: oneway function results will be dropped but finished with status OK and parcel size 4
2021-02-21 17:25:15.760 15156-15159/? I/cmd: oneway function results will be dropped but finished with status OK and parcel size 4
2021-02-21 17:25:15.817 15157-15157/? E/studio.deploy: Could not get package user id: run-as: unknown package: ai.fedml.android
2021-02-21 17:25:15.838 15157-15157/? E/studio.deploy: Could not find apks for this package: ai.fedml.android
2021-02-21 17:25:15.838 15157-15157/? E/studio.deploy: Error: 
2021-02-21 17:25:15.893 15165-15168/? I/cmd: oneway function results will be dropped but finished with status OK and parcel size 4
2021-02-21 17:25:16.741 494-514/? E/JobScheduler.Background: App com.google.android.gms became active but still in NEVER bucket
2021-02-21 17:25:16.744 494-526/? I/DropBoxManagerService: add tag=system_server_wtf isTagEnabled=true flags=0x2
2021-02-21 17:25:17.337 463-463/? E/wifi_forwarder: qemu_pipe_open_ns:62: Could not connect to the 'pipe:qemud:wififorward' service: Invalid argument
2021-02-21 17:25:17.337 463-463/? E/wifi_forwarder: RemoteConnection failed to initialize: RemoteConnection failed to open pipe
2021-02-21 17:25:18.758 494-526/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2021-02-21 17:25:18.758 494-526/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2021-02-21 17:25:46.616 15169-15172/? I/cmd: oneway function results will be dropped but finished with status OK and parcel size 4
2021-02-21 17:25:48.058 494-514/? E/JobScheduler.Background: App com.google.android.gms became active but still in NEVER bucket
2021-02-21 17:25:48.063 494-526/? I/DropBoxManagerService: add tag=system_server_wtf isTagEnabled=true flags=0x2
2021-02-21 17:25:48.078 13256-13256/? I/Finsky: (2) aosy.b(3): Verification requested, id = 18
2021-02-21 17:25:48.093 494-596/? W/AppIntegrityManagerServiceImpl: Exception reading file:///data/app/vmdl1167639721.tmp
    android.content.pm.PackageParser$PackageParserException: Failed to read manifest from /data/app/vmdl1167639721.tmp/base.apk
        at com.android.server.pm.parsing.PackageParser2.parsePackage(PackageParser2.java:155)
        at com.android.server.integrity.AppIntegrityManagerServiceImpl.getPackageArchiveInfo(AppIntegrityManagerServiceImpl.java:579)
        at com.android.server.integrity.AppIntegrityManagerServiceImpl.handleIntegrityVerification(AppIntegrityManagerServiceImpl.java:297)
        at com.android.server.integrity.AppIntegrityManagerServiceImpl.access$100(AppIntegrityManagerServiceImpl.java:97)
        at com.android.server.integrity.AppIntegrityManagerServiceImpl$1.lambda$onReceive$0$AppIntegrityManagerServiceImpl$1(AppIntegrityManagerServiceImpl.java:180)
        at com.android.server.integrity.-$$Lambda$AppIntegrityManagerServiceImpl$1$AQicMJqZVSufBnAD8HJ81gPtf7Y.run(Unknown Source:4)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.os.HandlerThread.run(HandlerThread.java:67)
     Caused by: java.lang.ClassCastException: android.content.pm.parsing.component.ParsedService cannot be cast to java.lang.String
        at android.content.pm.parsing.component.ComponentParseUtils.buildProcessName(ComponentParseUtils.java:100)
        at android.content.pm.parsing.component.ParsedMainComponentUtils.parseMainComponent(ParsedMainComponentUtils.java:83)
        at android.content.pm.parsing.component.ParsedServiceUtils.parseService(ParsedServiceUtils.java:60)
        at android.content.pm.parsing.ParsingPackageUtils.parseBaseApplication(ParsingPackageUtils.java:1845)
        at android.content.pm.parsing.ParsingPackageUtils.parseBaseApkTags(ParsingPackageUtils.java:753)
        at android.content.pm.parsing.ParsingPackageUtils.parseBaseApk(ParsingPackageUtils.java:494)
        at android.content.pm.parsing.ParsingPackageUtils.parseBaseApk(ParsingPackageUtils.java:372)
        at android.content.pm.parsing.ParsingPackageUtils.parseClusterPackage(ParsingPackageUtils.java:278)
        at android.content.pm.parsing.ParsingPackageUtils.parsePackage(ParsingPackageUtils.java:232)
        at com.android.server.pm.parsing.PackageParser2.parsePackage(PackageParser2.java:152)
        at com.android.server.integrity.AppIntegrityManagerServiceImpl.getPackageArchiveInfo(AppIntegrityManagerServiceImpl.java:579) 
        at com.android.server.integrity.AppIntegrityManagerServiceImpl.handleIntegrityVerification(AppIntegrityManagerServiceImpl.java:297) 
        at com.android.server.integrity.AppIntegrityManagerServiceImpl.access$100(AppIntegrityManagerServiceImpl.java:97) 
        at com.android.server.integrity.AppIntegrityManagerServiceImpl$1.lambda$onReceive$0$AppIntegrityManagerServiceImpl$1(AppIntegrityManagerServiceImpl.java:180) 
        at com.android.server.integrity.-$$Lambda$AppIntegrityManagerServiceImpl$1$AQicMJqZVSufBnAD8HJ81gPtf7Y.run(Unknown Source:4) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:223) 
        at android.os.HandlerThread.run(HandlerThread.java:67) 
2021-02-21 17:25:48.093 494-596/? W/AppIntegrityManagerServiceImpl: Cannot parse package ai.fedml.android
2021-02-21 17:25:48.094 494-544/? I/PackageManager: Integrity check passed for file:///data/app/vmdl1167639721.tmp
2021-02-21 17:25:48.098 13256-13256/? E/Finsky: (2) VerifyPerSourceInstallationConsentInstallTask.f(2): Package name null is not an installed package
2021-02-21 17:25:48.114 13256-15183/? I/Finsky: (1111) aouw.a(7): Single user settings service is not running, bind it now
2021-02-21 17:25:48.120 494-514/? E/JobScheduler.Background: App com.google.android.gms became active but still in NEVER bucket
2021-02-21 17:25:48.123 494-526/? I/DropBoxManagerService: add tag=system_server_wtf isTagEnabled=true flags=0x2
2021-02-21 17:25:48.124 13256-13256/? I/Finsky: (2) aouv.onServiceConnected(1): Single user settings service is connected
2021-02-21 17:25:48.134 13256-15183/? W/Settings: Setting install_non_market_apps has moved from android.provider.Settings.Global to android.provider.Settings.Secure, returning read-only value.
2021-02-21 17:25:48.146 13256-15183/? I/Finsky: (1111) VerifyAppsInstallTask.Z(5): Verify: Cannot read archive for file:///data/app/vmdl1167639721.tmp in request id=18, package=ai.fedml.android
2021-02-21 17:25:48.169 13256-15183/? I/Finsky: (1111) VerifyMissingSplitsInstallTask.mW(7): Could not tell if Splits is installed due to null packageInfo for id=18. Assuming not.
2021-02-21 17:25:48.169 13256-15183/? I/Finsky: (1111) VerifyMissingSplitsInstallTask.d(1): Assuming split not required due to null packageInfo for id=18
2021-02-21 17:25:48.170 13256-15183/? I/Finsky: (1111) VerifyPerSourceInstallationConsentInstallTask.mW(2): PSIC verification started with installer uid: 2000 package name: null, originating uid: -1
2021-02-21 17:25:48.173 13256-13256/? I/Finsky: (2) VerifyInstallTask.g(3): Verifying id=18, result=1
2021-02-21 17:25:48.175 13256-13256/? I/Finsky: (2) VerifyInstallTask.mU(6): Verification complete: id=18, package_name=ai.fedml.android
2021-02-21 17:25:48.185 494-544/? W/PackageManager: Failed parse during installPackageLI: Failed to read manifest from /data/app/vmdl1167639721.tmp/base.apk: android.content.pm.parsing.component.ParsedService cannot be cast to java.lang.String
2021-02-21 17:25:48.187 400-1293/? E/installd: Couldn't opendir /data/app/vmdl1167639721.tmp: No such file or directory
2021-02-21 17:25:48.187 400-1293/? E/installd: Failed to delete /data/app/vmdl1167639721.tmp: No such file or directory
2021-02-21 17:25:48.191 15178-15181/? I/cmd: oneway function results will be dropped but finished with status OK and parcel size 4
2021-02-21 17:25:48.263 494-3053/? W/ActivityManager: Invalid packageName: ai.fedml.android
2021-02-21 17:25:50.077 494-526/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2021-02-21 17:25:50.077 494-526/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2021-02-21 17:25:50.197 10955-10966/? I/.gms.persisten: Background young concurrent copying GC freed 114541(5966KB) AllocSpace objects, 41(2956KB) LOS objects, 45% free, 10MB/18MB, paused 991us total 109.268ms
2021-02-21 17:25:50.197 10955-10966/? W/.gms.persisten: Reducing the number of considered missed Gc histogram windows from 133 to 100

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="ai.fedml.android">
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.BROADCAST_STICKY" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_SMS"/>
    <uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>