Any way to sign an apk file without using eclipse - apk

I have an app which I want to sign and publish. I did not develop the app using eclipse. I have very little idea about programming. I have searched a lot of forums but could not find a way to do it. Can anyone explain the procedure to do it without using eclipse?

1 - You haven't done so, you'll need to create a new key, open the command line and type:
keytool -genkey -noprompt \
-alias eclipse \
-dname "CN=first and last name" \
-keystore "c:\path\keyname.key" \
-storepass password \
-keypass password \
-keyalg RSA \
-keysize 2048 \
-validity 10000
2 - Now you must sign the APK:
JAVA_HOME/bin/jarsigner
-verbose
-keystore c:\path\keyname.key
-storepass password
-keypass password
-signedjar DEV_HOME/bin/AndroidTest.signed.apk DEV_HOME/bin/AndroidTest.unsigned.apk AndroidTestKey
3 - Last step is to zipalign:
ANDROID_HOME/tools/zipalign
-v
-f 4 DEV_HOME/bin/AndroidTest.signed.apk DEV_HOME/bin/AndroidTest.apk
NOTES:
DEV_HOME is the location of you project
ANDROID_HOME is the Android SDK location
JAVA_HOME is the Java location

Signing process is documented here: https://developer.android.com/tools/publishing/app-signing.html

Related

Illegal option: Files\Android"Android Studio\jre\bin\keytool Key and Certificate Management Tool

I am trying to make apk file of my flutter app but facing problem i searched for this in Stackoverflow but not found any suitable answer which worked for me
i am using windows
C:\"Program Files"\Android\"Android Studio"\jre\bin\keytool -genkey -v -keystore c:\Users\SuD\upload-keystore -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
get following result
C:\\"Program Files"\\"Android"\\"Android Studio"\\jre\\bin\\keytool -genkey -v -keystore c:\Users\pprak\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
Please give path command in the above format. Use double \ in all the places where it mentions the Android SDK bin path.
See below images for the solution happened:-
1.) Did not applied double \ at all places. So it gave error.
2.) Added Double \ at all the places in path. So it did not give error.

Getting "BCFKS KeyStore corrupted: MAC calculation failed." error

I have a jks file and when i run the command keytool -keystore db-ssl-truststore.jks -list , i get the error
keytool error: java.io.IOException: BCFKS KeyStore corrupted: MAC calculation failed.
It seems, that you created keystore in BCFS format using the Bouncy Castle library.
If you want to see it in human-readable format, you can specify -storetype, -provider and -providerpath options for keytool:
keytool -keystore keystore.bckfs -storetype BCFKS -providerpath "bc-fips-1.0.2.jar" -provider org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider -list -v

how to sign APK with google upload key der file?

after importing the der file to the key store as follow
keytool -keystore my-release-key.keystore -importcert
-file ~/Downloads/upload_cert.der -alias uploadcert
I get an error when trying to assemble release APK
trusted certificate entries are not password-protected
If I add
-protected
to the import, I geth
keytool error: java.lang.IllegalArgumentException: password can't be null
and if I pass the password after -protected I get usage help message.
not sure how to pass the password.
Any idea if I am on the right path to sign with google upload certificate der file ?
Got the same problem and password can't be null problem may be passed by editing the comment like:
keytool -keystore parkimayaz.keystore -importcert -file
~/Downloads/upload_cert.der -alias uploadcert -keypass "yourpass" -
storepass "yourpass"
Another info I used characters like (',#,^) on the password part which gave me some errors.
also please take a look at oracle keytool docs

javalang.exception:key pair not generated, alias <androiddebugkey> already exists and java.io.filenotfoundexception:debug.keystore

I enter the following
keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
in cmd to generate debug keytool.
However, I received the error
java.io.filenotfoundexception:debug.keystore" instead. Afterwhich I changed the above command to "keytool -genkey -v -keystore C:\Users\me.android\debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
And this time I received another error
javalang.exception:key pair not generated, alias already exists
What goes wrong here? What I am trying to do here is just to generate a new debug keystore.
Found out that you need to delete the existing debug.keystore before generating a new debug.keystore. When generating a new debug.keystore, you need to list the directory where you want to store the keystore file.
After delete the old debug keystore, enter the below command in android studio terminal:
keytool -genkey -v -keystore debug.keystore C:\Users\abc\.android\debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000
Where debug.keystore is the name you want to define your keystore file, C:\Users\abc\.android\debug.keystore is the directory where you want to store the keystore
Based on a suggestion from others, I actually deleted debug.keystore, hence the file not found exception
Below worked:
- Retrieved debug.keystore back form recycle bin
- Reverted to old keys, instead of new upload keys. The old key was generated using android studio.
Reverted to old key is because play console rejected the upload of new app release as an update to older one.
when you creating next app (you always created one)there was alwasys upload-keystore.jks .so first you have to delete that. then paste your code in terminal
On Mac/Linux, use the following command:
content_copy
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload
On Windows, use the following command:
content_copy
keytool -genkey -v -keystore c:\Users\USER_NAME\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload
I encountered this error and what I had to do was to delete the upload-keystore.JKS file from the original path given when creating it the first time and the project itself. For me, I had to delete it from
My Project in Android studio
android/app folder
And also, from my computer
/Users/bojack folder

HTTPS for APIs : In Production

I am using Playframework for an API solution I have built. There are no HTML Pages served by my server, only API query responses in JSON. I know that playframework can support https with a self signed keys using Dhttps.port=9443.
It is written in the documentation that this is to be used only in Dev mode.
Since, I dont have webpages being served (and hence no browser warnings for self signed keys) and I am bothered only about encryption for API calls, can I use this for production too? or am I missing something ?
The documentation says that if you do not provide any certificate when you run the app in prod mode, Play will generate one and run it. This is discouraged because, the certificate is just a random stuff which you do not have any control on.
Coming to the question of using a private certificate, if you open the url in a browser, it warns the user of a "non-trusted-certificate". Since this is not the case with you and if your web server consumers are restricted to a confined set, I think you can use it in prod mode. Please consider other pros and cons of it too before proceeding.
In case you wish to go ahead, you can always generate a private certificate of your own and use it to run the app. Commands according to Play documentation for this are:
keytool -genkeypair -v \
-alias cert \
-dname "CN=<CHANGE ME>, OU=<CHANGE ME>, O=<CHANGE ME>, L=<CHANGE ME>, ST=<CHANGE ME>, C=IN" \
-keystore cert.jks \
-keypass a1AhzIabP1 \
-storepass a1AhzIabP1 \
-keyalg RSA \
-keysize 4096 \
-ext KeyUsage:critical="keyCertSign" \
-ext BasicConstraints:critical="ca:true" \
-validity 9999
Check the certificate using this command
keytool -list -v \
-keystore conf/cert.jks \
-storepass a1AhzIabP1
Then configure it in your application.conf like this
https.port=9443
play.server.https.keyStore.path="conf/cert.jks" # relative path to your certificate
play.server.https.keyStore.password="a1AhzIabP1"
Hope it helps!

Resources