10

I am using twitter4j in an android app for using twitter API. Everything works fine, and I have no problem with the library. Today I ran lint and getting lint errors in the twitter4j-core-3.0.3.jar. I dont have control over this third party library, so what should be done.

The lint error is as under:

Invalid package reference in library; not included in Android: javax.management.openmbean. Referenced from twitter4j.management.APIStatisticsOpenMBean.

Issue: Finds API accesses to APIs that are not supported in Android

Id: InvalidPackage

This check scans through libraries looking for calls to APIs that are not included in Android.

When you create Android projects, the classpath is set up such that you can only access classes in the API packages that are included in Android. However, if you add other projects to your libs/ folder, there is no guarantee that those .jar files were built with an Android specific classpath, and in particular, they could be accessing unsupported APIs such as java.applet.

This check scans through library jars and looks for references to API packages that are not included in Android and flags these. This is only an error if your code calls one of the library classes which wind up referencing the unsupported package.

peterh
  • 11,875
  • 18
  • 85
  • 108
Gaurav Vashisth
  • 7,547
  • 8
  • 35
  • 56

2 Answers2

10

If you are running Lint from the command line, you can provide a lint.xml in your project directory with the following config to ignore the twitter4j jar file.

<?xml version="1.0" encoding="UTF-8"?>
<lint>
    <issue id="InvalidPackage">
        <ignore path="libs/twitter4j-core-3.0.5.jar" />
    </issue>
</lint>

Comand line options for Lint can be found at http://developer.android.com/tools/help/lint.html

Akos Cz
  • 12,711
  • 1
  • 37
  • 32
  • 3
    To extend this answer: a certain package may also be included using the following type of statement: ` ` – Peter Jan 17 '16 at 16:14
4

For the time being I have just configured lint to ignore the error and show it as warning: To do so in eclipse goto Preferences-> Android -> Lint Error Checking, and change the severity of "InvalidPackage" to "Warning" or "Information" or "Ignore".

enter image description here

Gaurav Vashisth
  • 7,547
  • 8
  • 35
  • 56