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.
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
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.