Using Twitter4j in android, getting lint error in library - Invalid package reference in library

Gaurav Vashisth picture Gaurav Vashisth · Apr 24, 2013 · Viewed 7.3k times · Source

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.

Answer

Akos Cz picture Akos Cz · Jan 31, 2014

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