Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Unable to open PDF File on android #62

Open
insightopera opened this issue Jul 10, 2021 · 12 comments
Open

Unable to open PDF File on android #62

insightopera opened this issue Jul 10, 2021 · 12 comments

Comments

@insightopera
Copy link

insightopera commented Jul 10, 2021

Screenshot_1625916694

════════ Exception caught by widgets library ═══════════════════════════════════
The following _CastError was thrown building NotificationListener<KeepAliveNotification>:
Null check operator used on a null value

The relevant error-causing widget was
PDFViewer
lib/components/pdfViewer.dart:107
When the exception was thrown, this was the stack
#0      _PDFPageState._repaint
package:advance_pdf_viewer/src/page.dart:54
#1      _PDFPageState.didChangeDependencies
package:advance_pdf_viewer/src/page.dart:42

I have working where I create a pdf file and display on page.
It is working fine on ios devices.
But on android devices, it is showing this error message. Even share button is also sharing file but pdf view showing this error.
Please help to solve this error. After upgrade flutter 2 i am getting this message.

[✓] Flutter (Channel stable, 2.2.2, on Mac OS X 10.15.7 19H1217 darwin-x64, locale en-PK)
    • Flutter version 2.2.2 at /Users/student/Developer/flutter_2
    • Framework revision d79295af24 (4 weeks ago), 2021-06-11 08:56:01 -0700
    • Engine revision 91c9fc8fe0
    • Dart version 2.13.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/student/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    ✗ Xcode 11.5.0 out of date (12.0.1 is recommended).
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.58.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.24.0

[✓] Connected device (3 available)
    • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86    • Android 9 (API 28) (emulator)
    • macOS (desktop)              • macos         • darwin-x64     • Mac OS X 10.15.7 19H1217 darwin-x64
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 91.0.4472.114

! Doctor found issues in 1 category.
@FlawLessx
Copy link

Did you found a solution?

@insightopera
Copy link
Author

Did you found a solution?

No, But I changed the plugin which is working fine.

@EternalYouth29
Copy link

I am also facing this error. @amaajid001 which plugin are you using now ?

@DanielPiflaks
Copy link

DanielPiflaks commented Jul 25, 2021

I'm also having this issue.
It seems that on the first try to open the file it returns null from here:
var data = await _channel .invokeMethod('getPage', {'filePath': _filePath, 'pageNumber': page});
(From document.dart file)
And the interesting thing is that after I reopen my app everything works fine

Edit:
This patch solved this exception for me:
I have noticed that before I reopen the application (which solves the issue) and I try to open the PDF, I'm getting this exception:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.app.Activity.getResources()' on a null object reference

But when I reopen the app and everything works, this exception disappears. So, I have looked for this exception in this repository issues and encountered this fix:
#45

After implementing RasyidMF solution, the PDF opens correctly.

@insightopera
Copy link
Author

I am also facing this error. @amaajid001 which plugin are you using now ?

I am using syncfusion_flutter_pdfviewer this package.

@EternalYouth29
Copy link

I am also facing this error. @amaajid001 which plugin are you using now ?

I am using syncfusion_flutter_pdfviewer this package.

This syncfusion_flutter_pdfviewer works very well, too bad it is not a free package.

@insightopera
Copy link
Author

I am also facing this error. @amaajid001 which plugin are you using now ?

I am using syncfusion_flutter_pdfviewer this package.

This syncfusion_flutter_pdfviewer works very well, too bad it is not a free package.

Its free brother. I am using it.

@EternalYouth29
Copy link

Its free brother. I am using it.

You applied for the community license ?

@insightopera
Copy link
Author

Its free brother. I am using it.

You applied for the community license ?

No Just installed package from pub,dev
https://pub.dev/packages/syncfusion_flutter_pdfviewer

@EternalYouth29
Copy link

Its free brother. I am using it.

You applied for the community license ?

No Just installed package from pub,dev
https://pub.dev/packages/syncfusion_flutter_pdfviewer

But it stated "Disclaimer: This is a commercial package. To use this package, you need to have either a Syncfusion commercial license or Free Syncfusion Community license."

I have never used this kind of package before. Does it mean that we will have to have a license if we want to publish our app the app store?

@Andres-MI
Copy link

Any news on this topic or should I use another library?

@FlawLessx
Copy link

Any news on this topic or should I use another library?

Go get another library named pdf_native_viewer by serge.software

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants