Comments (11)
https://github.com/api-ai/apiai-android-client has transitive dependency on https://github.com/api-ai/apiai-java-client
Which adds log4j to your app.
log4j was not really designed to work on Android VM, so the best way to solve your issue is to use different implementation.
compile 'ai.api:sdk:2.0.5@aar'
// api.ai SDK dependencies
compile('ai.api:libai:1.4.8') {
exclude module: 'log4j-core'
}
The example below still uses log4j-api
as logging entry-point, but it excludes whole implementation nonsense.
Then, the simplest way to configure default logging is by log4j2.component.properties
resource file:
log4j2.loggerContextFactory=org.apache.logging.log4j.simple.SimpleLoggerContextFactory
Define default log level log4j2.simplelog.properties
org.apache.logging.log4j.simplelog.level=DEBUG
Similar thing can be achieved in code - just add to your Application class:
static {
LogManager.setFactory(new SimpleLoggerContextFactory());
// but SimpleLoggerContextFactory does not allow to override log level in runtime
// I guess you would need to play with root logger, but it's easier to set it in resource file
}
At the end, your logs would be visible in stderr
. Ofc, you may also do your own LoggerContextFactory
implementation.
from dialogflow-android-client.
I have the same but the app doesn't run fine for me - it crashes on pressing any button. This is on Android O Developer Preview but I understand that ManagementFactory was removed in API 20.
from dialogflow-android-client.
Seeing this issue on 7.1. Any work around for this issue ?
from dialogflow-android-client.
Lint reports all these imports not existing in Android:
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar: Invalid package reference in library; not included in Android: java.lang.management. Referenced from org.apache.logging.log4j.core.jmx.Server.
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar: Invalid package reference in library; not included in Android: javax.jms. Referenced from org.apache.logging.log4j.core.appender.mom.JmsAppender.
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar: Invalid package reference in library; not included in Android: javax.mail.internet. Referenced from org.apache.logging.log4j.core.net.MimeMessageBuilder.
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar: Invalid package reference in library; not included in Android: javax.mail.util. Referenced from org.apache.logging.log4j.core.net.SmtpManager.
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar: Invalid package reference in library; not included in Android: javax.mail. Referenced from org.apache.logging.log4j.core.net.SmtpManager.
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar: Invalid package reference in library; not included in Android: javax.management. Referenced from org.apache.logging.log4j.core.jmx.AppenderAdmin.
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar: Invalid package reference in library; not included in Android: javax.naming. Referenced from org.apache.logging.log4j.core.appender.db.jdbc.DataSourceConnectionSource.
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar: Invalid package reference in library; not included in Android: javax.persistence. Referenced from org.apache.logging.log4j.core.appender.db.jpa.JpaDatabaseManager.
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.2/c707664e020218f8529b9a5e55016ee15f0f82ac/log4j-core-2.2.jar: Invalid package reference in library; not included in Android: javax.xml.bind. Referenced from org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.ByteArrayConverter.
from dialogflow-android-client.
In my case, being a lint issue, I solved it by adding this configuration:
<issue id="InvalidPackage">
<ignore regexp="org.apache.logging.log4j.core.*"/>
</issue>
from dialogflow-android-client.
It crashes my app on Android O
java.lang.NoClassDefFoundError: org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at org.apache.logging.log4j.core.util.ReflectionUtil.instantiate(ReflectionUtil.java:185)
at org.apache.logging.log4j.core.lookup.Interpolator.(Interpolator.java:65)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:346)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:161)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:359)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:420)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:138)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:147)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:426)
at ai.api.AIDataService.(AIDataService.java:59)
at ai.api.android.AIService.(AIService.java:81)
from dialogflow-android-client.
Question, when mentioning "Then, the simplest way to configure default logging is by log4j2.component.properties resource file:"
Where and how to setup this file for an Android project?
from dialogflow-android-client.
@sergiandreplace Just put into src/main/resources
folder
> tail -vn +1 src/main/resources/*
==> src/main/resources/log4j2.component.properties <==
log4j2.loggerContextFactory=org.apache.logging.log4j.simple.SimpleLoggerContextFactory
==> src/main/resources/log4j2.simplelog.properties <==
org.apache.logging.log4j.simplelog.level=DEBUG
from dialogflow-android-client.
Thanks, now it works perfectly on Android 8, buuuut, lint is not happy about it. It returns the error:
Package not included in Android
../../../../../.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.2/d7ef6ad7ff0711dd12fe409d62d72d6ed14516e0/log4j-api-2.2.jar: Invalid package reference in library; not included in Android: java.lang.management. Referenced from org.apache.logging.log4j.message.ExtendedThreadInformation.
This check scans through libraries looking for calls to APIs that are not included in Android.
As the ExtendedThreadInformation class is referencing java.lang.management classes that are not included in Android.
One option is to ignore the error, but I'm not really happy ignoring InvalidPackage errors.
from dialogflow-android-client.
More info. If I remove the exclusion on log4j-core, the apps crashes, but lint says nothing about the java.lang.management issue, despite the classes are not there. This looks like a weird behaviour from Lint.
from dialogflow-android-client.
No news on this issue? We stopped using dialogflow because this (it was an experimental feature)
But, as @Vandalko said, log4j is not intended for android, so, why is this library using it?
I think df team should really remove it
from dialogflow-android-client.
Related Issues (20)
- sending payload from V1 SDK HOT 1
- AIButton fails to initialize after following instructions in Integration.md
- TTS HOT 3
- end_conversation
- On account of using Hindi in DialogFlow
- voice rocoginition took same text in multiple time
- Quick Reply
- Hii Any client for v2 for android HOT 1
- HttpClient cannot be used in the same project with dialogflow HOT 1
- Mic button is not working in android with web demo integration HOT 1
- How to migrate to Dialogflow API V2 and the v2 client library for android client? HOT 11
- Can not getting card or images?
- How to send recorded audio in AIService or get record audio through AIListener of dialogflow android
- URLs to be allowed when using dialogflow-android in restricted network. . . HOT 1
- Raw JSON is there in the console but not getting response in the console nor device
- Language support
- AIService Error
- Intent fulfillments HOT 2
- Authorization failed. Please check your access keys. Error Issues
- Hindi not supported
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dialogflow-android-client.