本文介绍了jarsigner错误:java.time.DateTimeException:MonthOfYear的值无效(有效值1 - 12):0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在签署Ionic安卓apk时遇到此错误,我在Kubuntu 17.04上,使用Ionic 3,安装了java 8

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

我得到的错误:

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版

$ 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

我安装了Android Studio并且工作正常,我测试了应用程序源代码,它在模拟器上运行没有问题。

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

解决方案

通过为与javac和javac版本匹配的jarsigner设置正确的update-alternative,可以在 Debian 9 上解决此问题。

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

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)

javac版本

$ javac -version
javac 1.8.0_141

jarsigner版本

Version of jarsigner

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

设置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

这篇关于jarsigner错误:java.time.DateTimeException:MonthOfYear的值无效(有效值1 - 12):0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 03:41