itextpdf - itextg Android lint error

592 Views Asked by At

I'm trying to use itextg but I'm getting some gradle errors. Any idea? I tried version 5.5.9 and 5.5.10.

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
    }
}
The first 3 errors (out of 482) were:
/Users/xxxxx/.gradle/caches/modules-2/files-2.1/com.itextpdf/itextg/5.5.10/247811bfc4d8f4e99c909236eadf4dfc6dfa1615/itextg-5.5.10.jar: Error: Invalid package reference in library; not included in Android: javax.xml.crypto.dom. Referenced from com.itextpdf.text.pdf.security.MakeXmlSignature. [InvalidPackage]
/Users/xxxxx/.gradle/caches/modules-2/files-2.1/com.itextpdf/itextg/5.5.10/247811bfc4d8f4e99c909236eadf4dfc6dfa1615/itextg-5.5.10.jar: Error: Invalid package reference in library; not included in Android: javax.xml.crypto.dsig.dom. Referenced from com.itextpdf.text.pdf.security.MakeXmlSignature. [InvalidPackage]
/Users/xxxxx/.gradle/caches/modules-2/files-2.1/com.itextpdf/itextg/5.5.10/247811bfc4d8f4e99c909236eadf4dfc6dfa1615/itextg-5.5.10.jar: Error: Invalid package reference in library; not included in Android: javax.xml.crypto.dsig.keyinfo. Referenced from com.itextpdf.text.pdf.security.MakeXmlSignature. [InvalidPackage]
2

There are 2 best solutions below

5
Sam On

Sounds like transitive libraries missing. Try using { transitives = true} on that dependency and see if it helps. Also it looks like they might be using straight Java modules for security underneath the hood, so you may have to make sure you specify the right JAVA_VERSION to use in your build.gradle as well.

Also confirm that you can expand the project view, to the itextg area and see the following JARs have been pulled in.

itextpdf-x.y.z.jar
itext-xtra-x.y.z.jar
itext-pdfa-x.y.z.jar
xmlworker-x.y.z.jar

If you don't see them, then you may need to download them and include them manually. I'm not familiar with itext enough to know how they include their transitive dependencies, but they do call it out on GitHub that they are used in this, so confirm they are there.

0
Edgar Vatamanitsa On

As far I understood, Android doesn't contain the following packages.

javax.xml.crypto.dom
javax.xml.crypto.dsig

That's why itextpdf lib can't find references to them. To fix it, add the following dependency.

implementation group: 'javax.xml.crypto', name: 'jsr105-api', version: '1.0.1'