Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 726
Gaurav Vashisth Avatar asked Apr 24 '13 05:04

Gaurav Vashisth


2 Answers

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

like image 171
Akos Cz Avatar answered Oct 21 '22 09:10

Akos Cz


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

like image 22
Gaurav Vashisth Avatar answered Oct 21 '22 11:10

Gaurav Vashisth