gpt4 book ai didi

android - Android 中的 transform.TransformException

转载 作者:行者123 更新时间:2023-11-29 19:12:28 27 4
gpt4 key购买 nike

当我尝试在运行时使用 iText 生成 PDF 时出现错误。当应用程序在设备或 geny Motion 中运行时会出现错误。

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/lowagie/bc/asn1/ASN1Encodable.class.

我的 Gradle 代码是:

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.visioneering.tfd"
minSdkVersion 15
targetSdkVersion 24
versionCode 5
versionName "1.5"
multiDexEnabled true

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
android {
lintOptions {
checkReleaseBuilds false
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}

}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.github.florent37:materialtextfield:1.0.5'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.google.android.gms:play-services:10.2.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.3'
compile 'com.googlecode.json-simple:json-simple:1.1'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.itextpdf:itext7-core:7.0.3'
compile 'com.itextpdf:itext-pdfa:5.5.11'
compile 'itext:itext:1.3.1'
compile 'org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.6'

}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

请帮我解决这个问题。

最佳答案

重复条目:com/lowagie/bc/asn1/ASN1Encodable.class - 指向 iText 2.1.7 或更早版本,不知道它是否与 Android 兼容。

您的 Gradle 文件中有几处错误:

  • compile 'com.itextpdf:itext-pdfa:5.5.11' - 指向与 Android 兼容的 iText 5 的 PDF/A 插件,版本 5.5.11,但您仍然需要 iText 5 的 Android 端口,称为 iTextG。所以你需要添加 compile 'com.itextpdf:itextg:5.5.10'。是的,5.5.10,不是5.5.11,因为没有itextg:5.5.11。参见 http://repo1.maven.org/maven2/com/itextpdf/itextg/
  • 猜测您认为“pdfa”中的“a”表示 Android,但事实并非如此。它代表 PDF/A:用于存档的 PDF 规范 (ISO 19005),请参阅 https://en.wikipedia.org/wiki/PDF/A .如果您不需要存档(在典型的 Android 应用程序中,您可能不需要),那么您可能需要删除 compile 'com.itextpdf:itext-pdfa:5.5.11 '
  • compile 'com.itextpdf:itext7-core:7.0.3' - 这是 iText 7,与 Android 不兼容。删除该行。
  • compile 'itext:itext:1.3.1' - 是 iText 的旧版本,可能是导致错误的原因。删除该行。
  • compile 'org.xhtmlrenderer:flying-saucer-pdf-itext5:9.1.6' - 这是一些特别的东西,我对此了解不够。它可能会或可能不会引入 iText 的另一个依赖项,这可能是也可能不是错误的版本。用 flying-saucer 标记您的问题以吸引更多关注。

关于android - Android 中的 transform.TransformException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44825873/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com