Skip to main content

Apksigner errors and solutions

The following errors may occur while signing with Apksigner:

jdk.crypto.cryptoki does not export sun.security.pkcs11 to unnamed module

Error message

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

Description

Java version 17 or lower is not configured for APK signing.

Solution

Use one of the following solutions outlined below:

  • Add the following parameter to the begining of the sign command:

    apksigner -J-add-exports"=jdk.crypto.cryptoki/sun.security.pkcs11=ALL-UNNAMED" <sign command>
  • Configure apksigner executable file for Java version 17 or lower, using the process below based on your operating system: