简体   繁体   中英

Adding iText 5.5.6 to Android project with gradle exception

I am trying to add the iTextPDF library to a Android project using Android Studio (gradle). I add the library with compile 'com.itextpdf:itextpdf:5.5.6' instruction but I am getting an error:

Error:Execution failed for task ':app:dexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/opt/jdk1.7.0_79/bin/java'' finished with non-zero exit value 2

My build.gradle is:

apply plugin: 'com.android.application'

android {
 compileSdkVersion 22
 buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "josealopez.com.software"
    minSdkVersion 14
    targetSdkVersion 22
    versionCode 104
    versionName "1.0.4"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/ASL2.0'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.couchbase.lite:couchbase-lite-android:1.0.4'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.itextpdf:itextpdf:5.5.6'
}

I put these two dependencies in the gradle:

compile 'com.itextpdf:itext-pdfa:5.5.10'
compile 'com.itextpdf:itextg:5.5.9'

Use these dependencies:

compile 'com.itextpdf:itext-pdfa:5.5.10'
compile 'com.itextpdf:itextg:5.5.10'
compile group: 'com.itextpdf.tool', name: 'xmlworker', version: '5.5.10'

我有这个问题尝试5.5.10它对我有用

compile 'com.itextpdf:itextg:5.5.10'

You may well have reached the 56k method limit. This can often happen when using Google Play Services which is huge and contains a lot of methods you probably don't need.

Instead of having the line compile 'com.google.android.gms:play-services:7.0.0' in your Gradle file try only using the individual modules you need from the Play Services library.

eg compile 'com.google.android.gms:play-services-location:7.0.0' to just use the location services.

A complete list is here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM