4

I use log4j in Android project, dependency defined in project gradle like:

compile 'log4j:log4j:1.2.16'

When Lint check happens, the analyser reports "InvalidPackage" errors:

../../../../../../../.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.17/5af35056b4d257e4b64b9e8069c0746e8b08629f/log4j-1.2.17.jar: Invalid package reference in library; not included in Android: java.awt. Referenced from org.apache.log4j.chainsaw.ControlPanel. ../../../../../../../.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.17/5af35056b4d257e4b64b9e8069c0746e8b08629f/log4j-1.2.17.jar: Invalid package reference in library; not included in Android: java.awt.event. Referenced from org.apache.log4j.chainsaw.Main.1.

....

How can I fix that the better way? Lint suggest to supress this warning by id, but this means supressing all warning by the type, am I right? This looks like not the best solution... Maybe some way to specify lint not to check the log4j package?

AndreyMan
  • 113
  • 8

1 Answers1

0

awt itself is not supported in Android.

Instead use the native Android graphics as detailed in How to add java.awt.image package in Android and other questions like 25488832: using-awt-classes-in-android

Of course this doesn't help much if you rely on a library which relies on awt . Possibly there is an Android version of such library.

(You may be OK using parts of a library which provokes this error. You can only use parts of the library which do not use awt, else, RTE. For this, your build process would have to tolerate the reaction from Lint. There are likely safer ways around this. )

Community
  • 1
  • 1
ElHombre55
  • 11
  • 3