This happened when using both the build-tools from android studio installation and from command line installation. My OpenJDK version is 11.0.18 (I also created the keystore with the keytool from it), and I tried both the 30.0.3 and 32 SDK versions.
I found a solution somehow. So, in your ‘build-tools’ folder, move the ‘apksigner.bat’ file in the ‘lib’ folder that you see there (the one that has ‘apksigner.jar’ in it). For some reason it falls back to using the lib folder completely instead and solves the problem. I’m still unsure if I did something wrong or this is a bug.
I have the same problem, but it is not solved in your way. I tried different versions of the SDK, but nothing helped. Maybe there are some other solutions to the problem?
make sure you have JRE_HOME and JAVA_HOME environment variables set properly. fixing them solved the issue in my case