binSaed / flutter_cached_pdfview

Enhanced PDF view for Flutter.
https://pub.dev/packages/flutter_cached_pdfview
MIT License
121 stars 70 forks source link

PDF preview fails for release mode - No implementation found for long com.shockwave.pdfium.PdfiumCore.o #94

Open CartmanGD opened 1 year ago

CartmanGD commented 1 year ago

I'm using flutter_cached_pdfview: ^0.4.1.

Here is my code:

const PDF().cachedFromUrl(
        widget.fileUrl,
        placeholder: (progress) => Center(
          child: SizedBox(
            width: MediaQuery.of(context).size.width / 2.5,
            child: LinearProgressIndicator(
              value: progress / 100,
              color: Colors.white,
              backgroundColor: Colors.grey,
            ),
          ),
        ),
        errorWidget: (error) => Center(child: Text(error.toString())),
      )

Everything works just fine in debug mode, but running the app in release mode shows a blank screen instead of the PDF preview.

I got the above log in logcat:

04-03 18:36:31.360 29300 29749 E .tenant_app.dev: No implementation found for long com.shockwave.pdfium.PdfiumCore.o(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_o and Java_com_shockwave_pdfium_PdfiumCore_o__ILjava_lang_String_2)

After disabling the shrinking option on build.gradle, the problem was solved.

android {
    ...
    buildTypes {
        release {
            ...
            minifyEnabled false
            shrinkResources false
            ...
        }
    }
}

It seems that there is an issue when shrinking this plugin.

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.6, on macOS 13.2.1 22D68 darwin-x64, locale en-IL)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.76.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability