Can't release build on my project. jarsigner error

I did as ionic official documentation says
http://ionicframework.com/docs/v1/guide/publishing.html

I made private key using keytool like below

keytool -genkey -v -keystore my-release-key.keystore -alias moontomoon -keyalg RSA -keysize 2048 -validity 10000

my-release-key.keystore is made.

then I tried to signed it with jarsigner

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore /User/jpd/express_user/platforms/android/build/outputs/apk/hello.apk moontomoon

then
Enter Passphrase for keystore:
I enter password that I enter when I made keystore

but It failed with error message saying
jarsigner: unable to open jar file: /User/jpd/express_user/platforms/android/build/outputs/apk/hello.apk

when I tried to input cli text without /User/jpd/express_user/platforms/android/build/outputs/apk/hello.apk moontomoon
then It says Please specify jarfile name

Does the file exist at that path?
How did you create it?
Any sudo usage along the way?

What is your ionic info output?

1 Like

I did all the command on Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin
where keytool and jarsigner is exist.

ionic info output is as follows :

cli packages: (/Users/jpd/express_user/node_modules)

@ionic/cli-utils  : 1.13.1
ionic (Ionic CLI) : 3.13.1

global packages:

cordova (Cordova CLI) : 7.0.1 

local packages:

@ionic/app-scripts : 2.0.0
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.5.0

System:

ios-deploy : 1.9.1 
Node       : v8.4.0
npm        : 5.3.0 
OS         : macOS High Sierra
Xcode      : Xcode 9.0.1 Build version 9A1004 

Misc:

backend : legacy

This is old and should be updated, but should not cause this problem.

These questions referred to /User/jpd/express_user/platforms/android/build/outputs/apk/hello.apk.

1 Like

/User/jpd/express_user/platforms/android/build/outputs/apk/hello.apk

is a project folder.

and I’m entering command on
Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin

I tried prefix sudo but didn’t work neither.
I tried this thinking there must be a problem on describing folder, so entered,

jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore hello.apk moontomoon
but didn’t work neither

That makes no sense. .apk is a file extension. This should be the file you created by running a build command.

You shouldn’t, my question was if you used sudo when creating the app or building the apk.

1 Like

oh my god :slight_smile:
I refered wrong file.

I did ionic cordova build --release android.
then android-release-unsigned.apk is made.
I should have referred android-release-unsigned.apk instead of hello.apk

.Thank you sujan ! you made it work out

1 Like

:smiley: :smiley:

(now I have to type something useless to be able to send this post)

hello guys i need a help i am stuk in a this problem from 2 days

i have generated the apk
i have zip alligned the apk

But when i am trying to upload the APK the error is coming as "This jar contains entries whose certificate chain is not validated "

then when i verified the apk if its signed i can see its signed but with 2 warnings

Can i get any help plzzz

2 Likes