I have created a Xamarin Form application using Visual Studio 2017 in Windows 10 and archived the android application to APK file.
When I upload the APK to Google Play console to update my existing app, it says the APK is not signed. Then I used this command to sign the APK using the same certificate
apksigner sign --ks <KEYSTORE_FILE_NAME> --ks-key-alias <ALIAS_NAME> <APK_FILE_NAME>
When I try to upload the signed APK, it says the APK is not zipaligned. Then I used this command to zipalign
zipalign -f -v 4 <OLD_APK_FILE_NAME> <NEW_APK_FILE_NAME>
When I upload the zipaligned APK to console, it says the APK is not signed. After I sign using apksigner it says it is not zipaligned. I am keep on circulating in the same circle again and again.
Even after I zipalign the APK first and then sign, Same error messages are displaying again and again in same circle.
Even if I used jarsigner, the situation is same.
I followed the steps given here
https://developer.xamarin.com/guides/android/deployment,_testing,_and_metrics/publishing/signing-the-app-package/manually-signing-the-apk/
But the APK not getting uploaded. What am I doing wrong?
Please note this is not a duplicate question.
apksigner requires you to zipalign prior to signing. jarsigner requires you to zipalign after signing. This is documented in the zipalign docs.
I have just finished and signed the apk through android studio,
then I have did an apk protect through apkprotect.com
when I am trying to upload the apk to play store I got this error " You uploaded an APK that is not zip aligned. You will need to run a zip align tool on your APK and upload it again. "
if I upload the original apk I got no errors,
I have tried to add zipalign true in the build.gradle but nothing happened
I have tried also disable and enable proguard .
You can run zipalign manually in command line:
zipalign [-f] [-v] <alignment> infile.apk outfile.apk
Note that zipalign is located inside ${sdk.dir}\tools
For more details visit zipalign
[Update]
Also, If you need to sign it you can run:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore YOURKEYSTORE unsigned.apk alias_name
(jarsigner is located inside java JDK_HOME/bin)
I got the same "You uploaded an APK that is not zip aligned... blah, blah" error when by mistake I tried to upload a DEBUG version of my .apk file to Google Play. It's a bit misleading error because the real problem is that you cannot distribute a debug version which additionally is not signed with your Google Android Developer key. (You can only upload an .apk compiled as release version, and it must be signed, which happens in the same step, at least if you're using Eclipse).
Make sure you distribute an .apk file which is your Signed Release version, as described here:
http://developer.android.com/tools/publishing/app-signing.html#releasecompile
This question and its answers are old; so we expect things to change. As of today, the zipalign tool is in the ANDROID_HOME directory under build-tools/[version]/ so my path is currently:
/android-sdk/build-tools/22.0.0/zipalign
Using the zipalign tool is not necessarily the answer here though, what you actually need to do is sign your apk.
Steps if using Xamarin for VS2017:
Build project
Right click and Archive project
Use Ad Hoc distribution channel
Sign your APK with your Signing Identity and Save As to produce an APK that is ZIP aligned.
Your APK can be uploaded to Google Play.
I was using Cordova, uploaded a signed APK but still got this error.
The ziptool is what helped me, it's located at ~AndroidSDK\build-tools\24.0.0\zipalign.exe
So for example :
"~\AndroidSDK\build-tools\24.0.0\zipalign.exe" -f -v 4 android-release-signed.apk android-release-signed-zipaligned.apk
I was using Cordova and the command line getting this error. I opened the project in Android Studio and used Android Studio to build the signed apk and the error went away.
When using the Cordova node.js CLI without going through Android Studio, it is necessary to update the PATH environmental variable to include the android build tools:
%ANDROID_HOME%\build-tools\29.0.2
Obviously the version number will change over time. Remember to close any CLI windows and re-open them to recognize the newly added path.
I am trying to upload my Android app to the Google Play market and I get the error:
the apk must be signed with the same certificates as the previous version
The funny thing is I am using the original keystone with the original passwords, so I am confused as to what could be causing this problem.
1) I did upgrade my Mac OS X to Lion which a 64 bit OS from I think the earlier 32 bit OS. Could that be the problem?
2) I did update the Android tools: Eclipse, SDK and Java before making this new app version. Could that be the problem?
3) I also tried running
jarsigner -verify -verbose -certs
on the old version of the app that is on Google Play and the new app and the certificate valid times are the same.
4) I created the new APK both manually and by using Export Android Application in Eclipse.
5) Manually I created the APK by within Eclipse using `
Android Tools -> Export Unsigned Application and then using
jarsigner -verbose -keystore mykeystore.keystore app.apk companyName
/Developer/android-sdk-mac_86/tools/zipalign -v 4 app.apk app_aligned.apk
So I don't think the problem is that I am using the wrong keystore. I've read that this problem could also be caused by
A) Trying to upload a debug apk instead of a release apk.
B) Having the wrong package name in the manifest.
C) Not incrementing the versionCode and versionName.
Are there other things that could cause this problem besides using the wrong keystone?
Well in my case it turns out I was using the wrong keystore. What lead me to realizing this was running
jarsigner -verify -verbose -certs android_app
on the previous and new app and getting a different CERT.RSA filename for each.
So I dug around a bit and found another keystore, which turned out to be the correct one.
I was trying to change my default/main/startup (whatever you call it) activity by editing the androidmanifest.xml file. All i did was change the android:name property. however, this completely broke the entire app. when I try to install it fails and reads.
Installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES
When I tried to change it back to its previous state, it was still giving me the same error... What have I done?
I found that this error can now also occur when using the wrong signing config. As described here, Android 7.0 introduces a new signature scheme, V2. The V2 scheme signs the entire APK rather than just the JAR, as is done in the V1 scheme. If you sign with only V2, and attempt to install on a pre-7.0 target, you'll get this error since the JARs themselves are not signed and the pre-7.0 PackageManager cannot detect the presence of the V2 APK signature.
To be compatible with all target systems, make sure the APK is signed with both schemes by checking both signature version boxes in Android Studio's Generate Signed APK dialog as shown here:
If only 7.0 targets are anticipated, then there is no need to include the V1 signature.
Did you edit the AndroidManifest.xml directly in the .apk file? If so, that won't work.
Every Android .apk needs to be signed if it is going to be installed on a phone, even if you're not installing through the Market. The development tools work round this by signing with a development certificate but the .apk is still signed.
One use of this is so a device can tell if an .apk is a valid upgrade for an installed application, since if it is the Certificates will be the same.
So if you make any changes to your app at all you'll need to rebuild the .apk so it gets signed properly.
I found this was caused by my JDK version.
I was having this problem with 'ant' and it was due to this CAUTION mentioned in the documentation:
http://developer.android.com/guide/publishing/app-signing.html#signapp
Caution: As of JDK 7, the default signing algorithim has changed, requiring you to specify the signature and digest algorithims (-sigalg and -digestalg) when you sign an APK.
I have JDK 7. In my Ant log, I used -v for verbose and it showed
$ ant -Dadb.device.arg=-d -v release install
[signjar] Executing 'C:\Program Files\Java\jdk1.7.0_03\bin\jarsigner.exe' with arguments:
[signjar] '-keystore'
[signjar] 'C:\cygwin\home\Chloe\pairfinder\release.keystore'
[signjar] '-signedjar'
[signjar] 'C:\cygwin\home\Chloe\pairfinder\bin\PairFinder-release-unaligned.apk'
[signjar] 'C:\cygwin\home\Chloe\pairfinder\bin\PairFinder-release-unsigned.apk'
[signjar] 'mykey'
[exec] pkg: /data/local/tmp/PairFinder-release.apk
[exec] Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
I signed the JAR manually and zipaligned it, but it gave a slightly different error:
$ "$JAVA_HOME"/bin/jarsigner -sigalg MD5withRSA -digestalg SHA1 -keystore release.keystore -signedjar bin/PairFinder-release-unaligned.apk bin/PairFinder-release-unsigned.apk mykey
$ zipalign -v -f 4 bin/PairFinder-release-unaligned.apk bin/PairFinder-release.apk
$ adb -d install -r bin/PairFinder-release.apk
pkg: /data/local/tmp/PairFinder-release.apk
Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]
641 KB/s (52620 bytes in 0.080s)
I found that answered here.
How to deal with INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES without uninstallation
I only needed to uninstall it and then it worked!
$ adb -d uninstall com.kizbit.pairfinder
Success
$ adb -d install -r bin/PairFinder-release.apk
pkg: /data/local/tmp/PairFinder-release.apk
Success
641 KB/s (52620 bytes in 0.080s)
Now I only need modify the build.xml to use those options when signing!
Ok here it is: C:\Program Files\Java\android-sdk\tools\ant\build.xml
<signjar
sigalg="MD5withRSA"
digestalg="SHA1"
jar="${out.packaged.file}"
signedjar="${out.unaligned.file}"
keystore="${key.store}"
storepass="${key.store.password}"
alias="${key.alias}"
keypass="${key.alias.password}"
verbose="${verbose}" />
Most of the time the solution for this error is really simple:
Uninstall your apk
Clean your Android project
Build your Android project
Install / run your apk
solved (for me) using in keytool the args
-sigalg MD5withRSA -keyalg RSA -keysize 1024
and using in jarsigner
-sigalg MD5withRSA -digestalg SHA1
solution found in
What kind of pitfals exist for the Android APK signing?
This error could be thrown if you add your signing config(create signing key and add to the "Project Structure" > "Modules" > "Signing Configs") but forget to point out in "Project Structure" > "Build Variants" > "Build Types" > "Signing Config".
The signing config field shouldn't be empty! (See the picture below) Otherwise, you will see
"INSTALL_PARSE_FAILED_NO_CERTIFICATES...APK signature verification failed."
error if you try to install a release variant. (or another variant with the same misconfiguration)
Recently I had this error while upgrading to Android Studio 4.0. The cause was that the project had V2 Signing Disabled in the signing configuration in build.gradle.
The solution was to remove v2SigningEnabled false or explicitly set it to true, which is the default value.
android {
signingConfigs {
dev {
v2SigningEnabled true
}
}
}
I was also facing the same issue. First I generated build using V2 and installed that in mobile devices running on OS 5.1 and I got the same issue. But build was working fine on Tablet running on OS 7.0. So I generated build with V1 Jar signature and it was working fine on both the devices.
Conclusion: If you are supporting the device below android OS 7.0. Use V1 jar signature to generate the build.
In my case, I could build and run release builds, but got the INSTALL_PARSE_FAILED_NO_CERTIFICATES error when trying to do a debug build.
The solution was to delete my debug.keystore file and let ADT recreate it. It had apparently expired.
A better long-term solution is to explicitly create a debug.keystore that does not expire after only a year, instead of letting ADT create it. Here is the command to do that:
keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -validity 14000
When prompted, enter these values:
First and last name: Android Debug
Organizational unit: Android
Name of organization: Unknown
City or Locality: Unknown
State or Province: Unknown
Country code: US
In my case, I was installing a project with MinimumSDK bigger than the Android version of my real device. I used another device and it solved.
My project MinSDK -> 24
My Phone Android version -> 21
In newer Android Studio versions 3.2+, if you are trying to run release install, and you have not defined any signing configurations, it will show the error prompt and install will fail. What you need to do is either run the debug build or set up the signing configuration (V1 or V2) correctly.
most answers are true . and some another reasons that happens are
► your min sdk smaller than device sdk.
► you have the older application in your device with the same package name
This is an ugly but fast solution: use JDK 6 instead of 7.
After read Chloe's answer, I uninstalled my JDK 7 (don't need it currently anyways) and installed JDK 6. That fixed it. A better solution would make ant uses JDK 6 (without uninstalling 7). Maybe possible changing / setting this property:
java.library.path
in local.properties file. It's in the project directory (root).
Android doesn't work with JDK 7 anyways (only 6 or 5), so make that the ant script also uses JDK 6 or 5 is probably a good solution.
Its because previously generated build and current is having conflict in signature version between v1(jar signature) and v2(full APK Signature),
To fix tick proper signature version under Generate Signed APK dialog
Also u can check
Project Structure -> Default Config -> Signing Config
after u add all that u need
Navigate to Run -> Edit Configurations... -> Android App -> app -> Installation Options
Then change to APK from app bundle instead of Default APK
This could happen if you try to include a .jar library that contains an AndroidManifest.xml file.
If it's pure Java make sure you don't include it in the .jar export
If it's not pure Java (meaning it's an Android project) then you have to include it as a Library Project
Maybe, you have changed the build variant from debug to release. Release variant requires a special certificate.
You can change build variant under menu build->select build variant... .
Setting environment variable JAVA_HOME to JDK 5 or 6 (instead of JDK 7) fixed the error.
I was getting this error because I did release that my ant release was failing because I ran out of disk space.
It's throwing this error for me today because I have an app with a min sdk of 28 and am hitting play on an emulator with an SDK version of 23. Usually this is not possible (AS gray's out the play button), but today not so much.
Make sure the build variant is set to debug (and not release) in Android Studio (check the build variants panel).
For me, I forget to add the new Signing Config into
Project Structure -> Default Config -> Signing Config
After some time and multiple online threads on the subject I managed to fix my project.
It's mainly taking into consideration the last files (could be images or layouts) that you put in. If you delete them, it will work out, and you can build your project again.
I was having this error in my Eclipse Console. It turns out that I had two jars with the same content but different names and they were conflicting with each other. I just deleted one of them and managed to install the app on the device.
I got this error when I tried to install a Xamarin project built against Android N preview on a phone running api v23. Solution is to not do that.
Another way to get this error is to build using ant on macOS and have a Finder icon file (Icon\r) in the source tree of the app. It appears jarsigner can't cope with the carriage return in the filename and, although it will claim the signing is valid if you -verify the APK, it always results in an APK that wont install on a device. Ironically, the Google Drive Finder plugin is a great source of Finder icon files.
The solution is to exclude the offending files (which are useless in the APK anyway) with a specifier like this in the fileset:
<exclude name="**/Icon
" />
This problem will happen if you are installing un-signed version of APK. Check if you are install correct APK.
I had that problem with ionic / Visual Studio Code (Run Android on device):
I uninstalled the App on the mobile device (Settings / Apps), the error is gone and the app is starting.
Firstly just try to do that:
go to Gradle script → bulid.gradle(module:app) → then you have to change (minSdkVersion) value. As an example, if you used 26 you can try to decrease the value, like (minSdkVersion 20 )
then try (sync now ).