iTextG Android 棉绒错误
iTextG Android Lint Error
:)
我有一个空的应用程序。我想添加依赖项。如果我 运行 gradle 构建任务一切正常。如果我将 itextg(Android 的 itext)添加到列表中,lint 会抛出错误。
这是我的依赖:
compile 'com.itextpdf:itext-pdfa:5.5.6-1'
它在 运行ning 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.6448fdba5df68602aed364b86fd14d89c07a66e\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.6448fdba5df68602aed364b86fd14d89c07a66e\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.6448fdba5df68602aed364b86fd14d89c07a66e\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.6448fdba5df68602aed364b86fd14d89c07a66e\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.6448fdba5df68602aed364b86fd14d89c07a66e\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 用于 "fixing"
我用
替换了依赖
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 is the android version of itext.
这是不正确的。
itext-pdfa
是一个 PDF/A (ISO-19005) 实现,它依赖于 itextpdf
(iText 核心 Java, 而不是 Android).
如果您的 Android 应用程序不需要 PDF/A 功能,那么您不需要依赖 itext-pdfa
.
正如 Bruno Lowagie 所写,itextpdf
使用 AWT 和其他在 Android 上不可用的东西。因此,如果您在 Android 应用程序中直接或通过传递依赖使用 itextpdf
,那么您确实会遇到构建错误。
iTextG 本质上是 iText 核心的精简版,所有 AWT 和其他 Android-不友好的东西都被剥离了。 (除了 iTextTest
,它似乎已经漏掉了,感谢您报告此问题!我们将在即将发布的 5.5.7 版本中修复它。) 但是,iTextG 仍然使用相同的 Maven 名称 itextpdf
,因此 itext-pdfa
等 iText 附加组件无需更改任何内容。在 Maven 中不能有两个同名的不同工件。
Maven 中目前没有 iTextG(Android 的 iText),您需要下载 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
作为依赖项,具体取决于您的应用适用于 desktop/server 或 Android/GAE。这应该不是问题,因为据我所知,大多数人总是向 itextpdf
或 itextg
添加显式依赖。
:)
我有一个空的应用程序。我想添加依赖项。如果我 运行 gradle 构建任务一切正常。如果我将 itextg(Android 的 itext)添加到列表中,lint 会抛出错误。
这是我的依赖:
compile 'com.itextpdf:itext-pdfa:5.5.6-1'
它在 运行ning 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.6448fdba5df68602aed364b86fd14d89c07a66e\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.6448fdba5df68602aed364b86fd14d89c07a66e\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.6448fdba5df68602aed364b86fd14d89c07a66e\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.6448fdba5df68602aed364b86fd14d89c07a66e\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.6448fdba5df68602aed364b86fd14d89c07a66e\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 用于 "fixing"
我用
替换了依赖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 is the android version of itext.
这是不正确的。
itext-pdfa
是一个 PDF/A (ISO-19005) 实现,它依赖于 itextpdf
(iText 核心 Java, 而不是 Android).
如果您的 Android 应用程序不需要 PDF/A 功能,那么您不需要依赖 itext-pdfa
.
正如 Bruno Lowagie 所写,itextpdf
使用 AWT 和其他在 Android 上不可用的东西。因此,如果您在 Android 应用程序中直接或通过传递依赖使用 itextpdf
,那么您确实会遇到构建错误。
iTextG 本质上是 iText 核心的精简版,所有 AWT 和其他 Android-不友好的东西都被剥离了。 (除了 iTextTest
,它似乎已经漏掉了,感谢您报告此问题!我们将在即将发布的 5.5.7 版本中修复它。) 但是,iTextG 仍然使用相同的 Maven 名称 itextpdf
,因此 itext-pdfa
等 iText 附加组件无需更改任何内容。在 Maven 中不能有两个同名的不同工件。
Maven 中目前没有 iTextG(Android 的 iText),您需要下载 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
作为依赖项,具体取决于您的应用适用于 desktop/server 或 Android/GAE。这应该不是问题,因为据我所知,大多数人总是向 itextpdf
或 itextg
添加显式依赖。