You dependency nimbus-jose-jwt does not have a declared dependency on bouncycastle, thus the error occurs if the environment does not provide a bouncycastle version itself. This happens this case on API Version 16.
While you could say, that this is a problem of the library, this is very likely done on purpose, because Bouncycastle is available for different JDK versions. The Bouncycastle project decided to use different Artifact names to reflect the different JDK Versions instead of reflecting it in the Bouncycastle version number.
This leads to problems in dependency management because the version resolver does not recognize the different versions to be actually the same artifact (which they technically are, since they contain a set of the same classes). And cannot resolve the version conflicts and therefore cannot throw version resolve errors e.g. on incompatible major versions.
org.bouncycastle » bcprov-jdk16
vs.
org.bouncycastle » bcprov-jdk15
vs.
org.bouncycastle » bcprov-jdk14
This can lead to multiple concurring versions of bouncycastle on the classpath, which in turn might lead to unpredictable classloader behavior or unpredictable classNotFound /Symbol not found errors (if an old version is used, while a newer is required).
The solution is simple:
Add the required dependency explicitly in your gradle file like this:
dependencies {compile 'org.bouncycastle:bcprov-jdk16:1.46'}
or
// https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk16
compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46'
If further libs are missing, try to identify the library which contains these classes (easiest is to google them) and add them explicitly as well.