APKSigner Errors and Solutions

Exception in thread "main" java.lang.IllegalAccessException

Error Message
Error: Exception in thread "main" java.lang.IllegalAccessException: class com.android.apksigner.ApkSignerTool$ProviderInstallSpec cannot access class sun.security.pkcs11.SunPKCS11 (in module jdk.crypto.cryptoki) because module jdk.crypto.cryptoki does not export sun.security.pkcs11 to unnamed module @72ea2f77

Problem

APKSigner is compatible with the following Java versions: Java 8, Java 11, and Java 17.

This issue occurs if a Java version other than the ones listed above is used to run APKSigner.

Solution

To use APKSigner, the system must have either Java 8, Java 11, or Java 17 installed.