iTextG Android Lint错误

iTextG Android Lint错误,android,itext,lint,itextg,Android,Itext,Lint,Itextg,:) 我有一个空的应用程序。我想添加依赖项。如果我运行gradle构建任务,一切都很好。如果我将itextg(Android的itext)添加到列表中,lint会抛出一个错误 这是我的依赖: compile 'com.itextpdf:itext-pdfa:5.5.6-1' 它在运行gradles生成任务时引发以下错误: :app:lint Ran lint on variant debug: 16 issues found Ran lint on variant release: 16 is

:)

我有一个空的应用程序。我想添加依赖项。如果我运行gradle构建任务,一切都很好。如果我将itextg(Android的itext)添加到列表中,lint会抛出一个错误

这是我的依赖:

compile 'com.itextpdf:itext-pdfa:5.5.6-1'
它在运行gradles生成任务时引发以下错误:

:app:lint
Ran lint on variant debug: 16 issues found
Ran lint on variant release: 16 issues found
Wrote HTML report to file:/D:/Git%20Projekte/Umsatzerfassung/app/build/outputs/lint-results.html
Wrote XML report to D:\Git Projekte\Umsatzerfassung\app\build\outputs\lint-results.xml
:app:lint FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lint'.
> Lint found errors in the project; aborting build.

Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
    lintOptions {
        abortOnError false
    }
}
...

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 43.762 secs
Lint found errors in the project; aborting build.

Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
    lintOptions {
        abortOnError false
    }
}
...
09:00:01: External task execution finished 'build'.
lint-results.html告诉我:

InvalidPackage: Package not included in Android
C:\Users\Dominic Fuchs\.gradle\caches\modules-2\files-2.1\com.itextpdf\itextpdf\5.5.6\19448fdba5df68602aed364b86fd14d89c07a66e\itextpdf-5.5.6.jar: Invalid package reference in library; not included in Android: java.awt.color. Referenced from com.itextpdf.awt.PdfGraphics2D.
C:\Users\Dominic Fuchs\.gradle\caches\modules-2\files-2.1\com.itextpdf\itextpdf\5.5.6\19448fdba5df68602aed364b86fd14d89c07a66e\itextpdf-5.5.6.jar: Invalid package reference in library; not included in Android: java.awt.geom. Referenced from com.itextpdf.awt.PdfGraphics2D.
C:\Users\Dominic Fuchs\.gradle\caches\modules-2\files-2.1\com.itextpdf\itextpdf\5.5.6\19448fdba5df68602aed364b86fd14d89c07a66e\itextpdf-5.5.6.jar: Invalid package reference in library; not included in Android: java.awt.image.renderable. Referenced from com.itextpdf.awt.PdfGraphics2D.
C:\Users\Dominic Fuchs\.gradle\caches\modules-2\files-2.1\com.itextpdf\itextpdf\5.5.6\19448fdba5df68602aed364b86fd14d89c07a66e\itextpdf-5.5.6.jar: Invalid package reference in library; not included in Android: java.awt.image. Referenced from com.itextpdf.awt.PdfGraphics2D.
C:\Users\Dominic Fuchs\.gradle\caches\modules-2\files-2.1\com.itextpdf\itextpdf\5.5.6\19448fdba5df68602aed364b86fd14d89c07a66e\itextpdf-5.5.6.jar: Invalid package reference in library; not included in Android: java.awt.print. Referenced from com.itextpdf.awt.PdfPrinterGraphics2D.
Priority: 6 / 10
Category: Correctness
Severity: Error
Explanation: Package not included in Android.
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.

More info:

To suppress this error, use the issue id "InvalidPackage" as explained in the Suppressing Warnings and Errors section.
请帮帮我。我不想用abortOnError=false来“修复”


我将依赖项替换为

compile fileTree(dir: 'libs', include: ['*.jar'])
我把itextg-5.5.4.jar放在我的libs文件夹中

新错误:

InvalidPackage: Package not included in Android
../../libs/itextg-5.5.4.jar: Invalid package reference in library; not included in Android: javax.management. Referenced from com.itextpdf.testutils.ITextTest.
Priority: 6 / 10
Category: Correctness
Severity: Error
Explanation: Package not included in Android.
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.

More info:

To suppress this error, use the issue id "InvalidPackage" as explained in the Suppressing Warnings and Errors section.
你写道:


itext pdfa是itext的android版本

这是不对的

itext-pdfa
是一种PDF/a(ISO-19005)实现,它依赖于
itextpdf
(itext-core for Java,而不是Android)

如果您的Android应用程序不需要PDF/A功能,那么您就不需要依赖于
itext pdfa

正如布鲁诺·洛瓦吉(Bruno Lowagie)所写,
itextpdf
使用AWT和其他Android上无法使用的东西。因此,如果在Android应用程序中直接或通过可传递依赖项使用
itextpdf
,那么确实会出现构建错误

iTextG本质上是一个精简版的iText core,去掉了所有AWT和其他对Android不友好的东西。(除了
iTextTest
,它似乎已经漏掉了,感谢您的报告!我们将在即将发布的5.5.7版本中修复它。)但是,iTextG仍然使用相同的Maven名称
itextpdf
,因此像
iText pdfa
这样的iText附加组件和其他附加组件不需要更改任何内容。在Maven中不能有两个同名的不同工件

目前Maven中没有iTextG(iText for Android),您需要下载
iTextG
jar并手动将其添加到您的Android项目中,如下面的答案所述:

然而,由于人们似乎对iTextG的Maven版本感兴趣,我们将对此进行研究。如果我们在Maven上发布iTextG,您仍然需要告诉您的构建工具(Maven,Gradle,…)排除
itextpdf
,并明确包含
iTextG
(或我们将要称之为的任何东西)

5.5.9
开始,iTextG位于Maven Central上,因此可以在您首选的构建工具(如Gradle)中使用。您需要
com.itextpdf:itextg:5.5.9

在附加组件(
pdfa
xtra
xmlworker
)中,
itextpdf
已声明为可选依赖项,因此
itextg
可作为替代项


如果您的应用程序声明了对其中一个加载项的显式依赖项,而没有对
itextpdf
的显式依赖项,这意味着
itextpdf
是一个可传递的依赖项,那么您必须显式地将
itextpdf
itextg
添加为依赖项,这取决于您的应用程序是针对桌面/服务器还是针对Android/GAE。这不应该是一个问题,因为据我所知,大多数人总是向
itextpdf
itextg
添加显式依赖项。

您声称正在使用,但您的错误消息告诉我们您正在使用iText。我更相信你的错误消息告诉我的,而不是你告诉我的,所以请改用iTextG而不是iText。iTextG是iText的Android端口。主要区别在于从iTextG中删除了对类的所有依赖项,如
java.awt.Color
。iTextG中没有
PdfGraphics2D
类(这也证明了您使用iTextG的说法是错误的)。itext pdfa是itext的android版本。itext-pdfa将itext作为编译依赖项。也许这就是原因?我将手动下载itextg jar并将其添加到我的文件树中。让我们试一试。:)我在上面编辑了我的帖子。啊哈,我看到iTextG中包含了
ITEXTEST
。这应该被删除。我会通知发布工程师。我们将在iText 5.5.7.aaah中解决此问题:)现在一切都清楚了。我在网上阅读了安卓系统中使用itext pdfa的任何教程。所以我认为a=android。谢谢你的解释!在Maven的iTextG会很棒。我正在使用Gradle。出于兴趣,你能给我那个教程的链接吗?我再也找不到了。对不起:/