Bug 56838 - error MSB6006: "jarsigner" exited with code 1.
Summary: error MSB6006: "jarsigner" exited with code 1.
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2017-05-25 14:16 UTC by James Clancey
Modified: 2017-06-23 17:31 UTC (History)
2 users (show)

See Also:
Tags: bb
Is this bug a regression?: ---
Last known good build:


Attachments

Description James Clancey 2017-05-25 14:16:59 UTC
This error happens when something is wrong with Signing.  We need a better error message to let people know to check their signing.
Comment 1 Jon Douglas [MSFT] 2017-06-23 17:28:22 UTC
I can confirm this behavior. Most external programs simply throw a code 0-255 but can also provide a diagnostic error/warning message with them that we should relay to the user through MSBuild's error list.

You can reproduce a similar error message by adding the following to a File->New Android Project's .csproj (Replace the old Release configuration):

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>PdbOnly</DebugType>
    <DebugSymbols>True</DebugSymbols>
    <Optimize>True</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidUseSharedRuntime>False</AndroidUseSharedRuntime>
    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
    <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
	    <AndroidKeyStore>True</AndroidKeyStore>
    <AndroidSigningKeyStore>filename.keystore</AndroidSigningKeyStore>
    <AndroidSigningStorePass>keystore.filename password</AndroidSigningStorePass>
    <AndroidSigningKeyAlias>keystore.alias</AndroidSigningKeyAlias>
    <AndroidSigningKeyPass>keystore.alias password</AndroidSigningKeyPass>
  </PropertyGroup>

You then attempt to archive the Release build:

Project "DroidBuildFail.csproj" (SignAndroidPackage target(s)):
Directory obj\Release\android/assets contains Bolts.AppLinks.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Bolts.Tasks.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Java.Interop.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.Animated.Vector.Drawable.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.Compat.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.Core.UI.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.Core.Utils.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.CustomTabs.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.Fragment.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.Media.Compat.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.v4.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.v7.AppCompat.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.v7.CardView.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Android.Support.Vector.Drawable.dll but no debug symbols file was found.
Directory obj\Release\android/assets contains Xamarin.Facebook.dll but no debug symbols file was found.
"jarsigner.exe" exited with code 1.

The important part here is that all we see is "jarsigner.exe" exited with code 1. This does not help empower the user to resolve the issue with their keystore. We should be providing error messages such as:

- No keystore found
- StorePass incorrect
- KeyAlias incorrect
- KeyPass incorrect

This is partly because jarsigner doesn't really help with errors:

https://docs.oracle.com/javase/9/tools/jarsigner.htm#GUID-925E7A1B-B3F3-44D2-8B49-0B3FA2C54864__BGBIIAAG

Thus it seems like we should be using -strict to help give a nice warning:

> During the signing or verifying process, the command may issue warning messages. If you specify this option, the exit code of the tool reflects the severe warning messages that this command found. See Errors and Warnings.

Which it seems like we do something similar in the AndroidSignPackage Task:

Task "AndroidSignPackage"
C:\Program Files\Java\jdk1.8.0_102\\bin\jarsigner.exe -keystore filename.keystore -storepass "keystore.filename password" -keypass "keystore.alias password" -digestalg SHA1 -sigalg md5withRSA -signedjar bin\Release\\App15.App15-Signed-Unaligned.apk "c:\Users\dougl\documents\visual studio 2017\Projects\App15\App15\obj\Release\android\bin\App15.App15.apk" keystore.alias 
jarsigner error: java.lang.RuntimeException: keystore load: c:\Users\dougl\documents\visual studio 2017\Projects\App15\App15\filename.keystore (The system cannot find the file specified)
"jarsigner.exe" exited with code 1.

Thus the relayed message to the user should be:

jarsigner error: java.lang.RuntimeException: keystore load: c:\Users\dougl\documents\visual studio 2017\Projects\App15\App15\filename.keystore (The system cannot find the file specified)

Note You need to log in before you can comment on or make changes to this bug.