I am building an Android app bundle (.aab) from Android Studio. The auto-generated build.gradle file contains this signingConfig section initially:
debug {
storeFile file('/keystores/test_android.jks')
storePassword 'something'
keyAlias 'test_key'
keyPassword 'something'
}
I have an hardware security module (HSM) which I use to protect my signing keys. In jarsigner, I can use it by calling the PKCS11 provider:
jarsigner -keystore NONE -storepass NONE -storetype PKCS11 -providerclass sun.security.pkcs11.SunPKCS11 -providerarg "$HOME/pkcs11.conf" -sigalg SHA256withRSA /artifacts/somelib-runtime-4.0.4.jar my_protected_key
I tried modifing the signingConfigs section to something like:
release {
storeFile file("NONE")
storePassword "NONE"
storeType "PKCS11"
providerName "sun.security.pkcs11.SunPKCS11"
providerArg "keystores/pkcs11.conf"
keyAlias "my_protected_key"
}
But I am getting below error when running gradle build.
Could not find method providerName() for arguments [sun.security.pkcs11.SunPKCS11] on SigningConfig$AgpDecorated_Decorated{name=release, storeFile=/Users/shenv/AndroidStudioProjects/MyApplication/app/NONE, storePassword=NONE, keyAlias=null, keyPassword=null, storeType=PKCS11, v1SigningEnabled=true, v2SigningEnabled=true, enableV1Signing=null, enableV2Signing=null, enableV3Signing=null, enableV4Signing=null} of type com.android.build.gradle.internal.dsl.SigningConfig$AgpDecorated.
How to make it work?