Issue with manually signing a Xamarin.Android apk

Shantimohan Elchuri 721 Reputation points
2020-11-30T18:54:00.67+00:00

I am following this article to manually sign an .apk. After zipalign issued the following command:

apksigner sign --ks <my-keystore> --ks-key-alias <my-alias> <my-package-name>.apk

But I am getting the following error after entering the Keystore password:

Keystore password for signer #1:
Failed to load signer "signer #1"
java.io.FileNotFoundException: esm.keystore (The system cannot find the file specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:93)
at com.android.apksigner.SignerParams.loadKeyStoreFromFile(SignerParams.java:352)
at com.android.apksigner.SignerParams.loadPrivateKeyAndCertsFromKeyStore(SignerParams.java:239)
at com.android.apksigner.SignerParams.loadPrivateKeyAndCerts(SignerParams.java:181)
at com.android.apksigner.ApkSignerTool.sign(ApkSignerTool.java:277)
at com.android.apksigner.ApkSignerTool.main(ApkSignerTool.java:83)

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,362 questions
0 comments No comments
{count} votes

Accepted answer
  1. Eelco De Vries 101 Reputation points
    2020-12-01T22:52:45.83+00:00

    I think the apksigner asks the password prior to locating the file to use it on.
    Tried the absolute path yet?

    apksigner sign --ks "C:\Users\shant\AppData\Local\Xamarin\Mono for Android\Keystore\esm.keystore" --ks-key-alias <my-alias> <my-package-name>.apk

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Eelco De Vries 101 Reputation points
    2020-11-30T20:42:11.287+00:00

    @Shantimohan Elchuri , if your keystore file is correctly spelled, it may be that it is not found at the expected location from where you execute the command. Try to run the command at the root of your project and use a relative path to where the file is located like;

    apksigner sign --ks ".\YourKeyStoreFileLocation\esm.keystore" --ks-key-alias <my-alias> <my-package-name>.apk

    Let me know if this helped.

    0 comments No comments

  2. Shantimohan Elchuri 721 Reputation points
    2020-12-01T13:52:21.373+00:00

    The keystore is in:

    C:\Users\shant\AppData\Local\Xamarin\Mono for Android\Keystore\esm.keystore

    I am running the apksigner command from the directory, where the apk is situated:

    <my-project>\Android\Release\bin\com.<my-company>.<my-app>.apk

    If it can't find the esm.keystore, then how come it is asking for the password? Isn't password embedded in the keystore file?

    I just repeated what I did a month ago without any errors. That's what is perplexing me.

    0 comments No comments

  3. Shantimohan Elchuri 721 Reputation points
    2020-12-02T19:44:52.47+00:00

    Yes, using the full path did resolve my issue.

    ThanQ...

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.