Sign an apk using keytool - android-studio

I want to sign an apk file using keytool , I have a public certificate .cer file and a private key .pem
I used to use the android studio wizard to sign apk , now I have no idea how to do it.

You can't sign an APK with keytool.
You can use jarsigner (doc) or apksigner (doc).
I highly recommend you sign with the latter (apksigner), since it has additional protections, is faster and is the recommended approach by the Android team.
apksigner is distributed via the SDK Build tools which you can download using the SDK Manager.
Then, the command line is:
apksigner sign --ks keystore.jks app.apk
where:
"keystore.jks" is the path to your keystore.
"app.apk" is the path the APK you want to sign.
You'll be prompted to enter the key alias from the keystore, then the password of the keystore and the password of the key. You can also enter those values on the command line if need be, e.g.
apksigner sign --ks keystore.jks --ks-key-alias AndroidDebugKey --ks-pass pass:android app.apk

Related

Signing and aligning apk files task is only signing one apk

My pipeline is getting succeeded but I need to get 3 signed APK's at artifacts. Only one of them is getting signed. I need all of them to get signed.
I'm using **/*.apk under APK files
And --verbose under apksigner arguments. Do I need to change anything here to get all of them signed.

Android stud. not building apk

my problem is that I want to make a signed apk file, I choose create signed apk file enter anything I need to enter, but the apk isn't appearing at the desktop (apk dest. location:Desktop)
Here is the build log:
Executing pre-compile tasks...
Running 'before' tasks
Checking sources
Running 'after' tasks
Finished, saving caches...
Executing post-compile tasks...
You can generate signed apk in menu build -> Generate signed bundle/apk. You may need to create keystore.jks and save it because when you upload on playstore, you can only use the same keystore file

Create certificate from a csr, crt and rsa file

The certificate provide me with the files mentioned above but I don't remember how to create a certificate file to install on iis, I remember using the openssl tool

You must sign an apk with the same signature as the app you are trying to certify - blockchainds.com : How to sign an apk file by Android Studio?

In according documentation of blockchainds.com (an apk market) I must to download an apk prepared by the site and then sign this apk with same signature as my main app(that is uploaded).
My problem:How I sign an apk file. I get erros. I can sign my project with the same signature.Also I can'not resign my own apk yet.How we could sign an apk file(not project) in android studio 3.2 ?
You can find details about signing an apk using android studio here You can check this video tutorial also.
Now for signing the blank apk from blockchainds you need to go to the directory where java is installed. Open Command prompt and type cd C:\Program Files\Java\jdk-9.0.1\bin (If you have changed the installation folder, use this same command but change the directory to the one you have selected during the installation of the SDK)
type in the following command, but with the following arguments:
jarsigner -keystore <path to the keystore file> <path to the unsigned APK> <keystore alias>
Example: jarsigner -keystore “C:\Users\Keystore\my_signature.jks" “C:\Users\Downloads\Unsigned_Test.apk” <your keystore alias name>
You will be asked to insert the password for your Keystore file, type it down and press enter. Your password is being inserted even if no text is shown!
If everything went right, the unsigned APK will be signed and you can now submit it.

How to obtain SHA1 certificate for Android studio 3.2.2?

I have seen many videos on how to obtain SHA1 certificate for Android Studio but they were all for other versions. There is no option for generating 'signed APK' in my Android Studio. Please help. Thanks in advance.
Fastest way to get SHA1 is through Android Studio.
Open gradle window from right side.
Right click on ProjectName-> Tasks-> android-> signingReport
Choose Run (1st option).
you will get SHA1 and MD5 inside your Run window at bottom which will be automatically opened after clicking on Run (Step 3).
Here is the Snapshot:-
Getting your SHA1 key is a little more complicated on a Windows system so, follow along with my steps here:
1) Open Command Prompt by pressing Start+R and typing cmd.exe.
2) Using Windows Explorer, find where your JDK directory is located (Usually Program Files >> Java) and copy the path.
3) In Command Prompt, type cd followed by the directory of your JDK’s bin directory. e.g: cd C:\Program Files\Java\jdk1.8.0_25\bin is the command I use (Yours may vary).
4) Using Windows Explorer, find where your .android directory is located (Usually under Users >> [YOUR WINDOWS USERNAME]) and copy the path.
5) Now, use this command below:
keytool -exportcert -alias androiddebugkey -keystore [PATH_TO_.ANDROID_DIRECTORY] -list -v
Replacing [PATH_TO_.ANDROID_DIRECTORY] with the path you copied. Note that you should be running this command in terminal/command prompt in your JDK’s bin directory (You did this in Step 3).
You should then be prompted with the password as normal which you can enter (The password is android) . After that, you’ll see the list of certificates printed to the screen. You want the SHA1 key.
In Command Prompt, it’s a little more tricky to copy the result so, to do that, follow these instructions:
1) Right-click on the Command Prompt.
2) Select Mark.
3) Highlight the SHA1 key.
4) Right-click again and the text will then be copied to your clipboard. You can now enter this on the Google Developer’s Console.

Resources