Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PlatformException in Release build: AbstractITextEvent is only for internal usage #2

Closed
abiselvaraj opened this issue Dec 29, 2022 · 6 comments

Comments

@abiselvaraj
Copy link

Hello,

I am using your library to edit existing PDFs. The app works properly when I test it in Debug mode, but I am receiving this error when I run the app in Release mode:

Unhandled Exception: PlatformException(removePdfPages_exception, java.lang.UnsupportedOperationException: AbstractITextEvent is only for internal usage.

Please help me understand the solution to resolving this issu. Thank you

@chaudharydeepanshu
Copy link
Owner

chaudharydeepanshu commented Dec 29, 2022

@abiselvaraj Sorry, for this issue. I should have provided the info in the documentation.

You will need to create a file named proguard-rules.pro in your project Android->App->proguard-rules.pro.

In that file you need to add the below block of text at the end of the file.

# To use iText in release mode Otherwise we get
# PlatformException AbstractITextEvent is only for internal usage.
-keep public class com.itextpdf.**
-keep public class org.apache.**

Let me know if you have anymore queries.

@abiselvaraj
Copy link
Author

Thank you for your reply.
I did come across that solution through a stackoverflow thread, but it does not work, as I found out that proguard is obsolete now and gradle gives you an error when you try enable it through app/build.gradle by using proguard: true.

@chaudharydeepanshu
Copy link
Owner

chaudharydeepanshu commented Dec 29, 2022

Sorry to hear that. But can you share an example project?

Because I have been using it in my release apps with the above solution.

Also I didn't have to use proguard: true.

Full repository link: https://github.com/chaudharydeepanshu/files_tools

@chaudharydeepanshu
Copy link
Owner

@abiselvaraj Also, below is the config I use for release in my App->build.gradle.

buildTypes {
        release {
            // Enables code shrinking, obfuscation, and optimization for only
            // your project's release build type.
            minifyEnabled true

            // Enables resource shrinking, which is performed by the
            // Android Gradle plugin.
            shrinkResources true

            // Includes the default ProGuard rules files that are packaged with
            // the Android Gradle plugin. To learn more, go to the section about
            // R8 configuration files.
            proguardFiles getDefaultProguardFile(
                    'proguard-android-optimize.txt'),
                    'proguard-rules.pro'

            signingConfig signingConfigs.release

            ndk {
                debugSymbolLevel 'FULL'

                // By default, the app bundle contains your Dart code and the Flutter
                // runtime compiled for armeabi-v7a (ARM 32-bit), arm64-v8a (ARM 64-bit), and x86-64 (x86 64-bit).
                // For reference see https://docs.flutter.dev/deployment/android#build-an-app-bundle.
                // But without these filters in case of some 3rd party plugins supporting x86 it will generates x86 folder
                // marking the app compatible with x86 even when its not, this will lead to crash on x86 devices.
                // For more info see https://github.com/flutter/flutter/issues/73943#issuecomment-979741146.
                abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86_64'
            }
        }
}

@abiselvaraj
Copy link
Author

Your config file should be able to help me out. I guess I access the configuration files using the obsolete method. I will try this one out. Thank you very much.

@chaudharydeepanshu chaudharydeepanshu changed the title Library doesnt work in release mode, but works in debug mode PlatformException in Release build: AbstractITextEvent is only for internal usage Dec 29, 2022
@chaudharydeepanshu
Copy link
Owner

@abiselvaraj No problem. If you still face problems with it then let me know we will reopen it.

chaudharydeepanshu added a commit that referenced this issue Dec 29, 2022
…some devices in some case of PDF compressing.

* Updated documentation regarding PlatformException in Release build: AbstractITextEvent is only for internal usage [#2](#2).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants