I had an issue with Gradle which I have fixed by adding export JAVA_OPTS="-Djava.ext.dirs=" to my .bashrc (also tried adding to .profile and /etc/environment but to no avail)
Gradle now functions correctly and I can build my project from the command line, however if I run Android studio I still get the same issue.. It seems like Android studio is either ignoring (which it explicitly says it doesn't.. the gradle launch script says the user should use JAVA_OPTS to pass arguments) or setting that env variable to "".
For reference the issue (it has to do with conflicting logging Jar being loaded) is:
./gradle
FAILURE: Build failed with an exception.
* What went wrong:
org.slf4j.impl.Log4jLoggerFactory cannot be cast to org.gradle.logging.internal.slf4j.OutputEventListenerBackedLoggerContext
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.