android - package conflicts with an existing package by the same name -
i have problem upgrade apk not install due above message.
i have read posts on message happens when app signed different release key.
example post on different keys
. in logs try upgrade apk 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 installed or not 04-07 13:28:04.378 3675-3845/? w/packagemanager: package com.xxx.rr3 signatures not match installed version; ignoring!
. orginal app has been in production on 4 years , written using eclipse, installed on old hard drive.
6 months ago boss bought me ssd drive , installed android studio. migrated old project , builds fine , install on device doesn't have previous version installed.
i copied keystore old hard drive new ssd , use sign new version of app in android studio. have ever used 1 same keystore, same passwords , alias.
can tell me why android saying upgrade signed different key?
[update1]
i have extracted cert.rsa both old , new apk. both use same keystore , keys noticed using wrong release alias. below fingerprints both apks top 1 old 1 bottom, new one.
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 ;z.b ] ] c:\openssl-win64\bin>keytool -list -keystore .keystore keytool error: java.lang.exception: keystore file 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 specified correct releasealias when clicking on 'generate signed apk' there still error albeit different.
the package conflicts existing package same name
. have tried build new apk manually, using following 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 c:\users\mattheww\.gradle\wrapper\dists\gradle-2.14.1-all\8bnwg5hd3w55iofp58khbp6yv failure: build failed exception. * where: build file 'c:\users\mattheww\studioprojects\nfcscanner3\app\build.gradle' line: 1 * went wrong: problem occurred evaluating project ':app'. > java.lang.unsupportedclassversionerror: com/android/build/gradle/appplugin : unsupported major.minor version 52.0 * try: run --stacktrace option stack trace. run --info or --debug option more log output. build failed total time: 29.982 secs
.
if keystore , fingerprints match on both apps, can explain why new app still not upgrade?
[update 2]
i have remembered when imported eclipse project android studio, not build correctly. there problem appication object. appication object called nfcscannerapplication , have class implemented same name (which described in manifest).
once imported android studio, built , pushed on device, android said not find application class. used following code seemed solve 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; } // above method commented out , used //because migration process eclipse android //needed it. see below //https://stackoverflow.com/questions/36495954/bootstrapapplication-cannot-be-cast-to-applicationclass
it uses reflection application class. reason why though i'm using same keystore etc, android thinks there different app on device same name?
[update 3] seem have found problem. :) have contentprovider gets application context when app first loaded. call getcontext , cast application class.
what call getcontext.getapplicationcontext() , works fine now. below code use , old code iscommented out above.
//old code //context context = getcontext(); //nfcappobj = (nfcscannerapplication) getcontext(); //new code context applicationcontext = getcontext().getapplicationcontext(); nfcappobj = getrealapplication(applicationcontext);
if have old apk can use details of cert used sign it. (extract cert.rsa file apk -unziping it-, running openssl aplication on file.)
unzip -p app.apk meta-inf/cert.rsa |openssl pkcs7 -inform der -noout -print_certs -text
then use keytool (that comes java) list certificates key store, , see if find match, or if certificate think correct matches.
for reference:
Comments
Post a Comment