Android Question Cannot install app: The package conflicts with an existing package by the same name. [Solved]

Kevin

Well-Known Member
Licensed User
Longtime User
I'm getting this error when trying to install an updated APK. I haven't worked on this app for a while and intend to make some improvements.

For now, all I did was change some settings in the manifest and then tried to re-install the app. Basically, I was expecting it to fail to copy a file to external storage because there currently is no code to check for run-time permissions. Instead, it failed to install altogether!

I changed min sdk from 12 to 16, and target sdk from 19 to 26:
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26"/>

Initially, I forgot to change the Private sign key file from my "business" one to my "personal" one, but I thought of that the first time it failed and still no luck.

So I have confirmed the following:

  • The package name is identical to what I previously used (obviously, hence the error)
  • The keystore (private sign key) is the same file I previously used
  • The password is correct (I actually use the same password for both the business & personal sign keys)
  • I tried increasing the version code by one, and still no luck
  • I am referencing Android.jar v27, if it makes any difference, which is much higher than previously used
  • I tried Tools>Clean Project numerous times

I am using B4A Wireless bridge. B4A is v8. This app was probably last changed several major B4A versions prior.

Any ideas? I could change the package name but this is an app I made for work and others use it too.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Each app should have a unique packagename.
This should be first you define in a new app.
Strg-b to call the buildconfig and define a new packagename
Errr - he's effectively trying to install a new build of the same app. There is no need to change the package name if the private sign key is the same as previous.

@Kevin - have you tried uninstalling the app from the device first (& also make sure it's uninstalled for all users on your device if you have more than 1 user)? Also, triple-check that you are using the same signing key. Is it possible that it got changed since the last time you worked on the app?

- Colin.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
I tried installing via USB/ADB and the error message was a bit clearer and said the signature doesn't match. I tried signing with both sign keys and the problem occurs with both of them.

I seem to recall an update to Windows a while back that was updating something regarding encryption. I'm now wondering if the issue is a result of that update and the PC is doing something different with regard to using my private key to create a digital signature. I really don't know how that sign key gets processed into the APK.

I'm certain the sign key is the same. I have several copies of them and they all have the original 'last edited' date.

I also read something about 1024 bit keys being deprecated so I'm trying to figure this out. My concern is that this is going to cause a big problem with my published (particularly, paid) apps if something has changed in how my sign keys are utilized. I might try compiling on another computer later.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
My keys are from 2011 and never an issue until now. Something is going on with this particular app. I recompiled a few of my other apps and they updated just fine.

I'm definitely not using the debug key, but I tried that too just for shits and giggles. Same result. So now I have tried both of my original sign keys (the only two I have ever had) as well as the debug key and it keeps saying that the signature doesn't match.

The only difference I can think of is that the copy of the app that is currently installed on the phone was originally an email attachment that went through my employer's Exchange server. This seems like a reach but I wonder if they have something installed that examines APK files and re-signs them with a different key. It sounds crazy (and probably is) but I really can't figure this out.

Is there any way I can take the old APK and somehow compare its signature with a freshly generated version on my PC (i.e. the Objects folder)? I don't need to figure out which sign key was used... I just want to see how the signature compares to what it should be.

At this point, about all I can do is just have it uninstall the existing app and install the "new" one, but I really would love to figure this out before doing something that will prevent me from ever knowing what really happened.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User

That solved it! When it was last compiled, it was indeed using the debug key. This was too long ago for me to remember any details, but I am thinking perhaps that the last update I made to this app was with a fresh install of B4A on one of my computers and I neglected to set my private sign key. If not, then I have no idea how it would get changed to the default debug key because once it's set, it's set, from what I understand.

I ended up moving on with my current update (still in progress) but I am very relieved to know what happened. Thanks Colin!

On a side note: I wonder if the debug key changes with Android or B4A versions, because when I tried the default debug key, it still didn't match the previously installed APK.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
On a side note: I wonder if the debug key changes with Android or B4A versions, because when I tried the default debug key, it still didn't match the previously installed APK.

Possibly. Dunno though, because I never use it. Glad you got it sorted!

- Colin.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…