0

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]
Yamila
  • 443
  • 1
  • 9
  • 20

2 Answers2

4

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'
0

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.

Sam
  • 5,342
  • 1
  • 23
  • 39
  • did you also confirm JAVA_VERSION required by this library and make sure you are targeting the same JAVA_VERSION as the library is requiring? and confirm above JARs are there as well – Sam May 09 '18 at 20:06
  • It's Android: compileSdkVersion 27, buildToolsVersion '27.0.3' – Yamila May 09 '18 at 21:23
  • That's not Java. Those are Android Tool Versions. Also you did not confirm the JARs are in your project structure – Sam May 09 '18 at 22:00
  • ItextG is a modified version of iText 5, where we have taken away the Java parts that are incompatible with Android. I am not familiar with Android development myself so I wouldn't know how to reproduce, and our office is closed until Monday anyway. – Amedee Van Gasse May 10 '18 at 07:13
  • Hi Amedee, All Android libraries are Java under the hood, so you cannot remove the Java Parts. Every library is compiled against a specific JDK, and if your parent project is using a later JDK then the child project it will conflict. I've run into this personally. – Sam May 11 '18 at 15:40