6

I get this error when signing an Ionic android apk, I'm on Kubuntu 17.04, using Ionic 3, java 8 installed

The error I get:

Enter Passphrase for keystore: 
updating: META-INF/MANIFEST.MF
adding: META-INF/TEST2.SF
adding: META-INF/TEST2.RSA
signing: AndroidManifest.xml
jarsigner error: java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 0

java version

$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.17.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)

javac

$ javac -version
javac 1.8.0_131

I have Android Studio installed and it's working fine, I tested the app source code and it ran on the emulator no problems.

MomenSh
  • 355
  • 1
  • 3
  • 13

2 Answers2

5

This issue could be solved on Debian 9 by setting the correct update-alternative for jarsigner that matches the version of java and javac.

Version of java

$ java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-8u141-b15-1~deb9u1-b15)
OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode)

Version of javac

$ javac -version
javac 1.8.0_141

Version of jarsigner

$ sudo update-alternatives --get-selections | grep jarsigner
jarsigner   manual   /usr/lib/jvm/java-8-openjdk-amd64/bin/jarsigner

To set the version of jarsigner

$ sudo update-alternatives --config jarsigner
There are 4 choices for the alternative jarsigner (providing /usr/bin/jarsigner).

  Selection    Path                                             Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-9-openjdk-amd64/bin/jarsigner   1091      auto mode
  1            /usr/bin/gjarsigner-4.9                           1049      manual mode
  2            /usr/bin/gjarsigner-6                             1060      manual mode
* 3            /usr/lib/jvm/java-8-openjdk-amd64/bin/jarsigner   1081      manual mode
  4            /usr/lib/jvm/java-9-openjdk-amd64/bin/jarsigner   1091      manual mode
Marvin
  • 175
  • 1
  • 6
  • I had the same issue with version 9, after updating to 10, the problem is gone. Here you can find how to install/update version 10 or later: https://stackoverflow.com/a/49507161/6053654 – P.S. Aug 16 '18 at 16:28
1

I had the same error. But my java version is 9.0.1,after switched my jdk version to 1.8.xx, the error was gone. So, change the jdk version may solve the problem.

Michael Yang
  • 1,403
  • 2
  • 18
  • 27