Package conflicts with existing package with the same name

I have a problem when updating to my apk will not be installed due to the above message.

I read SO posts that say this message occurs when an application is signed with a different release key.

example of a message on different keys

. In my logs, when I try to update apk, I get the following:

04-07 13:28:03.796 2072-2072/? W/InstallAppProgress: Replacing package:com.xxx.rr3 04-07 13:28:04.326 3675-3845/? W/PackageManager: verifying app can be installed or not 04-07 13:28:04.378 3675-3845/? W/PackageManager: Package com.xxx.rr3 signatures do not match the previously installed version; ignoring! 

. The original application has been released for over 4 years and was written using Eclipse, which is installed on my old hard drive.

6 months ago, my boss bought me an SSD drive and I installed Android Studio. I transferred the old project, and it works fine, and it will be installed on a device that does not have a previous version installed.

I copied the keystore from my old hard drive to my new SSD, and I use it to sign a new version of the application in Android Studio. Therefore, I used only one keystore with the same passwords and aliases.

Can someone tell me why Android says my update is signed with a different key?

[Update1]

I extracted CERT.RSA for the old and new apk. They both use the same key store and keys, but I noticed that I used the wrong release alias. Below are the fingerprints for both apks, the upper one is old, lower, new.

 C:\OpenSSL-Win64\bin>keytool -printcert -file CERT.RSA Owner: CN=matthew womersley, OU=dev, O=carefreegroup, L=wakefield, ST=west yorkshire Issuer: CN=matthew womersley, OU=dev, O=carefreegroup, L=wakefield, ST=west yorkshire Serial number: 6144ad2c Valid from: Fri Jan 11 08:55:29 GMT 2013 until: Thu May 14 09:55:29 BST 3012 Certificate fingerprints: MD5: 50:63:5E:54:9D:D3:C4:71:A9:4E:3C:F4:27:9E:50:CA SHA1: 7C:2C:DB:7E:92:D2:01:46:43:8D:D2:B9:A4:D2:B0:F4:85:E7:16:D9 SHA256: 38:64:89:4D:A2:37:72:AA:CE:90:5E:34:46:B9:D0:A4:CA:18:B7:07:7A:E2:DB:1D:7C:60:CD:70:F6:77:C5:FF Signature algorithm name: SHA256withRSA Version: 3 Extensions: #1: ObjectId: 2.5.29.14 Criticality=false SubjectKeyIdentifier [ KeyIdentifier [ 0000: 3F 95 E8 FA 36 5B 26 07 33 72 8B 09 37 0C 18 C5 ?...6[&.3r..7... 0010: 3B 5A 19 42 ;ZB ] ] C:\OpenSSL-Win64\bin>keytool -list -keystore .keystore keytool error: java.lang.Exception: Keystore file does not exist: .keystore C:\OpenSSL-Win64\bin>keytool -printcert -file CERT.RSA Owner: CN=matthew womersley, OU=dev, O=carefreegroup, L=wakefield, ST=west yorkshire Issuer: CN=matthew womersley, OU=dev, O=carefreegroup, L=wakefield, ST=west yorkshire Serial number: 6144ad2c Valid from: Fri Jan 11 08:55:29 GMT 2013 until: Thu May 14 09:55:29 BST 3012 Certificate fingerprints: MD5: 50:63:5E:54:9D:D3:C4:71:A9:4E:3C:F4:27:9E:50:CA SHA1: 7C:2C:DB:7E:92:D2:01:46:43:8D:D2:B9:A4:D2:B0:F4:85:E7:16:D9 SHA256: 38:64:89:4D:A2:37:72:AA:CE:90:5E:34:46:B9:D0:A4:CA:18:B7:07:7A:E2:DB:1D:7C:60:CD:70:F6:77:C5:FF Signature algorithm name: SHA256withRSA Version: 3 

I pointed out the correct releases when I clicked "Generate Signed Apk", but still there is an error, although another.

Package conflicts with existing package with the same name

. I tried to create a new apk manually using the following link:

link

 C:\Users\mattheww\StudioProjects\nfcscanner3>gradlew assembleRelease Downloading https://services.gradle.org/distributions/gradle-2.14.1-all.zip Unzipping C:\Users\mattheww\.gradle\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv\gradle-2.14.1-all.zip to C:\Users\mattheww\.gradle\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\mattheww\StudioProjects\nfcscanner3\app\build.gradle' line: 1 * What went wrong: A problem occurred evaluating project ':app'. > java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 29.982 secs 

.

If the keystore and fingerprint storage are the same in both applications, can someone explain why the new application will still not be updated?

[UPDATE 2]

I just remembered that when I imported the Eclipse project into Android Studio, it would not be built correctly. There was a problem with the application object. My application object is called NfcScannerApplication, and I have a class implemented with the same name (which is also described in the manifest).

After importing into Android Studio, built-in and connected to the device, Android stated that it could not find the application class. so I used the following code that seemed to solve the problem.

 public static NfcScannerApplication getRealApplication (Context applicationContext) { Log.e(TAG, "inside NfcScannerApplication getRealApplication"); NfcScannerApplication application = null; if (applicationContext instanceof NfcScannerApplication) { application = (NfcScannerApplication) applicationContext; } else { Application realApplication = null; Field magicField = null; try { magicField = applicationContext.getClass().getDeclaredField("realApplication"); magicField.setAccessible(true); realApplication = (Application) magicField.get(applicationContext); } catch (NoSuchFieldException e) { Log.e(TAG, e.getMessage()); } catch (IllegalAccessException e) { Log.e(TAG, e.getMessage()); } application = (NfcScannerApplication) realApplication; } return application; } // the above method is commented out and this is used //because the migration process from Eclipse to Android //needed it. see below //https://stackoverflow.com/questions/36495954/bootstrapapplication-cannot-be-cast-to-applicationclass 

It uses reflection to get the Application class. Could this be the reason that although I use the same keystore, etc., Android believes that there is another application on the device with the same name?

[UPDATE 3] I seem to have found the problem. :) I have a ContentProvider that gets the application context when the application loads first. I call getContext and pass it to the application class.

Now I get a call to getContext.getApplicationContext (), and now it works fine. Below is the code I'm using now, and the old code is listed above.

 //old code //Context context = getContext(); //nfcAppObj = (NfcScannerApplication) getContext(); //new code Context applicationContext = getContext().getApplicationContext(); nfcAppObj = getRealApplication(applicationContext); 
+7
android android-studio apk
source share
3 answers

If you have an old apk, you can use it to get information about the certificate used to sign it. (Extract the CERT.RSA file from apk -unziping it, and then run the openssl application in this file.)

 unzip -p App.apk META-INF/CERT.RSA |openssl pkcs7 -inform DER -noout -print_certs -text 

Then use keytool (which comes with java) to list the certificates from your keystore, and see if you find a match, or if the result you really think is correct.

For reference:

Getting certificate information from apk

How do I know which keystore was used to sign the application?

0
source share

Post your signed apk to the play store in beta or alpha if the play store rejects your apk, which means your keystore is not the original one.

If the Play Store accepted your apk, try updating the installed apk from the play store.

If your application is not listed in the play store, you can pull the previous apk from the device and compare the signature APKs SHA1

to get SHA1 apk How do I know which key store was used to sign the application?

0
source share

If you don’t do something special when you click the β€œPlay” button in Android Studio, he will use a temporary special debug key to subscribe to the application, and then he will install it on your device.

Eclipse did something very similar.

If you're talking about using Android Studios "Generate Signed APK", try the following debugging steps:

  • Install apk via adb manually, see if an error still occurs.
  • Sign the apk yourself through gradle if the error still occurs.

If both of these actions do not work, I think it is reasonable to assume that you are not using the same key as before.

0
source share

All Articles