Noclassdeffounderror: com.itextpdf.text.Document error after updating SDK

Asked

Viewed 52 times

2

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

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

Document document = new Document(); 

The error that occurs:

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

I didn’t change the class, I just upgraded the version of SDK 22 to SDK 23.

I’m having this problem on devices prior to Android 5.0. Version 5 onwards 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 of what might be?

  • Welcome to sopt. Your question is somewhat incomprehensible, a lot of code mixed with loose texts, it is difficult to understand. First explain what is.

  • This problem started to appear after I upgraded the sdk to 23, I use asynctask to call in the background, but it gives error. Strange that it’s only on some devices. The same code worked well before, I did the debug apk test and the only one that worked at all was the one that used sdk 22

  • I have two device for testing, one with version 5.1 that works normally is one with version 4.3 that stopped generating the pdf. I haven’t tried it in the emulator because if it worked before, it might be something with sdk I don’t know, I’m a beginner in Java programming. And I have no idea where to start.

  • I gave an improved question to make it easier for people to understand, any additional information they find necessary, just edit the question.

  • Thank you Diego, it’s the first time I put something on, because I couldn’t find a solution.

1 answer

2

Problem solved.

In logcat appeared the following message, before the error.

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

And searching the Internet, I found that it might be something related to multiDexEnabled which is not required in previous versions, and also by calling all google dependencies compile 'com.google.android.gms:play-services:8.4.0', that in this case I removed that I put only what I needed. that’s where it worked.

I don’t really know the solution but some dependency on Google was in conflict.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.