Caused by: java.lang.NoSuchMethodException: no such method: org.apache.logging.log4j.util.StackLocator
Clash Royale CLAN TAG#URR8PPP
Caused by: java.lang.NoSuchMethodException: no such method: org.apache.logging.log4j.util.StackLocator
After updating AndroidStudio to the latest 3.1.x version gradle complained that annoationProcessors has to be declared separately and suggests that I add 'org.apache.logging.log4j:log4j-core:2.10.0' to my annoationProcessor config.
I added it which results in the following error in this run task:
run tasks
:app:transformClassesWithDesugarForAppDebug 11s 442ms
error:
Caused by: java.lang.NoSuchMethodException: no such method: org.apache.logging.log4j.util.StackLocator.lambda$getCallerClass$3(String,String,Stream)Optional/invokeStatic
Caused by: java.lang.NoSuchFieldError: method resolution failed
I have also tried to disable the annoation check with this instead of adding the line above:
defaultConfig
...
javaCompileOptions
annotationProcessorOptions
includeCompileClasspath false
All this results in the same error above.
I have not added this library as a dependency meaning its part of some other library I'm importing but I'm not sure which.
Is there a way to...
DependencyInsight:
Configure project :androidlib
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
2 Answers
2
I'd guess you'd have to add both packages, log4j-api
& log4j-core
...because it says that org.apache.logging.log4j.util
is the Internal utility classes for the Log4j 2 API
.
log4j-api
log4j-core
org.apache.logging.log4j.util
Internal utility classes for the Log4j 2 API
dependencies
api "org.apache.logging.log4j:log4j-api:2.11.1"
implementation "org.apache.logging.log4j:log4j-core:2.11.1"
one can list all/specific module's dependencies alike this:
./gradlew :app:dependencies >> ./results/dependencies.txt
./gradlew :app:dependencies --configuration debugCompileClasspath
in order to list all the available configurations:
./gradlew :app:dependencies | grep ' - ' | grep -v '(n)' | grep -v 'deprecated'
then one can list the dependencies per individual build configuration:
./gradlew :app:dependencyInsight --configuration debugCompileClasspath --dependency log4j-core
have not tried that, but have you ever tried something alike ...
dependencies
annotationProcessor "org.apache.logging.log4j:log4j-core:2.11.1"
here's the annotationProcessor migration documentation.
@just_user and what does
dependencyInsight
say?– Martin Zeitler
Aug 13 at 6:54
dependencyInsight
that
StackLocator
might be wrongfully constructed, logging.apache.org/log4j/2.x/log4j-api/apidocs/org/apache/… ...there is no getCallerClass(String,String,Stream)
.– Martin Zeitler
Aug 13 at 6:57
StackLocator
getCallerClass(String,String,Stream)
Yes, that's what i find strange. The project worked before with the same dependencies and then some android studio updates came in between and now this error. I have added the output of the dependencyInsight to the question. Complains about google-services.json, is that related?
– just_user
Aug 13 at 7:04
Found this issue which seems to be more or less the same: github.com/gradle/gradle/issues/2384#issuecomment-376793947
– just_user
Aug 13 at 7:19
In the end I had to remove all libraries including org.apache.logging.log4j:log4j-core:2.10.0
to make it work.
org.apache.logging.log4j:log4j-core:2.10.0
But look through Martin Zeitler's answer as its very helpful!
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Thanks for all the suggestions. I have tried them all now but still haven't been able to get rid of the error.
– just_user
Aug 13 at 6:51