NoClassDefFoundError error: com.itextpdf.text.Document after updating the SDK

2

I have a database on sqlite on Android, and export report to pdf using the itextpdf library.

But recently after updating the Android SDK, it started from the error line below:

Document document = new Document(); 

The error that occurs:

  

Caused by: java.lang.NoClassDefFoundError: com.itextpdf.text.Document

I did not modify the class, I only upgraded the version of SDK 22 to SDK 23.

I'm having this problem on devices prior to Android 5.0. From version 5 onwards it works normally.

Before:

dependencies {
    compile 'com.itextpdf:itextpdf:5.5.8'
    compile 'com.android.support:support-v4:22.2.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.android.gms:play-services:7.5.0'
}

Now:

defaultConfig {
        multiDexEnabled true
}
android {
    useLibrary 'org.apache.http.legacy'
}
dependencies {
    compile 'com.itextpdf:itextpdf:5.5.8'
    compile 'com.android.support:support-v4:23.2.1'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.google.android.gms:play-services:8.4.0'
}

Does anyone have any suggestions for what it might be?

    
asked by anonymous 19.03.2016 / 00:28

1 answer

2

Problem solved.

In logcat the following message appeared before the error.

  

Could not find class 'com.itextpdf.text.Document',

And searching the internet, I found that it could be something related to multiDexEnabled that is not necessary in previous versions, and also because I called all dependencies of google compile 'com.google.android.gms:play-services:8.4.0' , which in that case I removed that I put only what needed. That's where it worked.

I'm not sure the solution, but some dependency on Google was in conflict.

But it is a warning to use only the necessary and always check the logcat, which informed the class lack even before the error.

    
21.03.2016 / 22:10