0

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.
chaybs
  • 13
  • 4
  • possible duplicate of [Where to declare environment variables?](http://askubuntu.com/questions/4667/where-to-declare-environment-variables) – muru Aug 10 '15 at 08:37
  • Don't add it to `.bashrc`. Add it to `.profile` and re-login. – muru Aug 10 '15 at 08:37
  • Tried both .profile and /etc/environment to no avail.. I can successfully run gradle via the command line however Android Studio still fails listing the cause as the aforementioned issue in its log file. There is another workaround [here](https://issues.gradle.org/browse/GRADLE-1451) however it is on Mac. When I search my computer for that .jar I have about 20 or so instances of it.. I tried moving the ones in any path which contained 'ext' however the issue is still present. – chaybs Aug 10 '15 at 11:12
  • Did you login again after changing `.profile`? – muru Aug 10 '15 at 11:23
  • Yep, restarted after both – chaybs Aug 10 '15 at 12:09
  • OK managed to get it working, ditched the environment variable method and instead deleted (well moved, in case it breaks something else in the future) the .jars slf4j-log4j12-1.5.8.jar and slf4j-api-1.5.8.jar from /usr/java/packages/lib/ext/ Regardless, thank you for your help muru, also how do I mark this as the solution? – chaybs Aug 10 '15 at 13:26
  • Since you're a new user, it will take time, but you can mark your answer as accepted using the tick next to it. – muru Aug 10 '15 at 13:39

1 Answers1

0

OK solved it, delete (or better move, in case it breaks something else in the future) the .jars slf4j-log4j12-1.5.8.jar and slf4j-api-1.5.8.jar from /usr/java/packages/lib/ext/

chaybs
  • 13
  • 4