[ https://issues.apache.org/jira/browse/LOG4J2-1921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16076259#comment-16076259 ]
Ajitha edited comment on LOG4J2-1921 at 7/6/17 9:45 AM: -------------------------------------------------------- Android does not support Java 9 classes. It throws error in StackLocator.class: {code:java} AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: Dex cannot parse version 53 byte code.\nThis is caused by library dependencies that have been compiled using Java 8 or above.\nIf you are using the \u0027java\u0027 gradle plugin in a library submodule add \ntargetCompatibility \u003d \u00271.7\u0027\nsourceCompatibility \u003d \u00271.7\u0027\nto that submodule\u0027s build.gradle file.\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class","sources":[{}],"original":"PARSE ERROR:\nunsupported class file version 53.0\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class\n","tool":"Dex"} AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]} {code} was (Author: ajitha): Android does not support Java 9 classes. It says: {code:java} AGPBI: {"kind":"error","text":"Error converting bytecode to dex:\nCause: Dex cannot parse version 53 byte code.\nThis is caused by library dependencies that have been compiled using Java 8 or above.\nIf you are using the \u0027java\u0027 gradle plugin in a library submodule add \ntargetCompatibility \u003d \u00271.7\u0027\nsourceCompatibility \u003d \u00271.7\u0027\nto that submodule\u0027s build.gradle file.\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class","sources":[{}],"original":"PARSE ERROR:\nunsupported class file version 53.0\n...while parsing META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class\n","tool":"Dex"} AGPBI: {"kind":"error","text":"1 error; aborting","sources":[{}]} {code} > Getting ClassCastException while getting LoggerContext > ------------------------------------------------------ > > Key: LOG4J2-1921 > URL: https://issues.apache.org/jira/browse/LOG4J2-1921 > Project: Log4j 2 > Issue Type: Bug > Components: Configurators > Affects Versions: 2.8.2 > Environment: Android > Reporter: Ajitha > Priority: Blocker > Labels: Android > > Hi, > I integrated the log4j with my Android application and did the initial > config. It works fine. I have a menu item in "Settings" screen where I can > change the log levels in my application. So, After I change the > configuration, I need to update the loggers. So I am using following logic. > {code:java} > LoggerContext ctx = LoggerContext.getContext() > Configuration config = ctx.getConfiguration(); > LoggerConfig loggerConfig = > config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME); > loggerConfig.setLevel(myLogLevel); > ctx.updateLoggers(); > {code} > While getting the logger context, I am getting a ClassCastException. > 05-26 22:33:21.011 E/AndroidRuntime( 9642): Caused by: > java.lang.ClassCastException: > org.apache.logging.log4j.simple.SimpleLoggerContext cannot be cast to > org.apache.logging.log4j.core.LoggerContext > 05-26 22:33:21.011 E/AndroidRuntime( 9642): at > org.apache.logging.log4j.core.LoggerContext.getContext(LoggerContext.java:190) > 05-26 22:33:21.011 E/AndroidRuntime( 9642): at > org.apache.logging.log4j.core.config.Configurator.setRootLevel(Configurator.java:323) > Please help here. -- This message was sent by Atlassian JIRA (v6.4.14#64029)