'ADB "App already installed" Error despite the fact that the app is not installed

I am currently trying to upload an apk for a Unity project to my Pixel 3a. I am using ADB and am running into an issue regarding installation: When I use adb install <app>, I get the message

adb: failed to install testingApp.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.DefaultCompany.com.unity.template.mobile2D signatures do not match previously installed version; ignoring!]

From what I know this indicates that a version of the app is already installed on the Phone. This shouldn't be the case, as this is the first time I have tried to upload the apk to my phone. When I attempt to uninstall this "already installed version" using adb uninstall <app>, I get the message

Failure [DELETE_FAILED_INTERNAL_ERROR]

I have checked the app list on my phone, and have not found this app in the list, nor have I seen it in the list of installed apks.

Can someone please explain to me why my phone thinks it's installed this app even though it hasn't?

(One extra bit of info that might be useful... I've been able to install a unity app build to my phone before, and it is still on the device, although the phone doesn't put it in the apk list of my apps)



Solution 1:[1]

It is possible to uninstall an app but keep the app data. In such a case the newly installed app have to have the same signature as the uninstalled app. Base don the error message you get I would assume that this happend somehow and now it prevents you from installing the new app version.

To ignore the existing data you can force Android to replace the app using -r "replace existing application" option:

adb install -r <app>

If you can change the packageName of the app to be installed changing it would also be an option.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Robert