:)
我有一个空的应用程序。我想添加依赖项。如果我运行 gradle build 任务一切都很好。如果我将 itextg(适用于 Android 的 itext)添加到列表中,lint 会引发错误。
这是我的依赖:
compile 'com.itextpdf:itext-pdfa:5.5.6-1'
它在运行 gradles build 任务时抛出以下错误:
: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.