Error:Failed to resolve: com.itextpdf:itextpdf:4.2.2

Error:Failed to resolve: com.itextpdf:itextpdf:4.2.2

我正在尝试使用 itext 库在 android 中创建 pdf 文件。但是每当我 运行 这个项目时,我都会收到以下错误。

Error:Failed to resolve: com.itextpdf:itextpdf:4.2.2

我在 gradle 中输入了以下依赖项。

compile 'com.lowagie:itext:4.2.2'
compile 'com.itextpdf:itextg:5.5.9'

有人可以帮忙吗?我在互联网上搜索了很多,但一无所获。

当你想创建一个Android应用程序时,你需要使用iTextG,所以这是正确的:

compile 'com.itextpdf:itextg:5.5.9'

但是,您还导入了一个无法在 Android 上运行的流氓版本的 iText:

compile 'com.lowagie:itext:4.2.2'

您需要删除该依赖项。

请将包名与我的名字进行比较:Lowagie。我是 iText 的原始开发者,由于很多人私下联系(甚至骚扰我)关于 iText 的问题,我在 2009 年将包名从 com.lowagie 更改为 com.itextpdf。那是将近 8 年前的事了。

如果您在代码中看到我的名字,那么 you are doing something wrong。将所有 import com.lowagie 实例替换为 import com.itextpdf 因为我在 8 年前从打包名称中删除了我的名字。