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

[Bug] HTML to PDF not working on Android 10 #66

Closed
Tims159 opened this issue Jul 20, 2020 · 11 comments
Closed

[Bug] HTML to PDF not working on Android 10 #66

Tims159 opened this issue Jul 20, 2020 · 11 comments

Comments

@Tims159
Copy link

Tims159 commented Jul 20, 2020

Description

HTML to PDF not working on Android 10

Steps to Reproduce

  1. HTML to PDF service
  2. Android 10

Note : both ExternalStorage Persmission also added to manifest still issue persists.
Issue not present before on same nuget package 2.3.0, so might be some dependency issue.
Issue after Visual Studio update from 16.6.3 to 16.6.4.

Expected Behavior

PDF should be generated

Actual Behavior

throws
Java.IO.IOException
Message=Permission denied

Basic Information

  • Version with issue:
  • Last known good version: 2.3.0
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android: 10
    • UWP:
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices: Pixel 2 XL

Screenshots

Reproduction Link

Workaround

Quck fix for now

Add android:requestLegacyExternalStorage="true" to application tag in manifest.

@Tims159 Tims159 changed the title [Bug] [Bug] HTML to PDF not working on Android 10 Jul 20, 2020
@baskren
Copy link
Owner

baskren commented Jul 22, 2020

@Tims159

Just shared a PDF from the HTML Export page of the demo app to GMAIL on an Android 10 device without incident. Sure would be a lot easier to help if you had shared a Reproduction Link.

@Tims159
Copy link
Author

Tims159 commented Jul 23, 2020

@Tims159

Just shared a PDF from the HTML Export page of the demo app to GMAIL on an Android 10 device without incident. Sure would be a lot easier to help if you had shared a Reproduction Link.

Issue is present only if Target Framework is Android 10(Q) in Android Options even for demo app.

its because the Android.OS.Environment.GetExternalStoragePublicDirectory(string) is depreciated.

@baskren
Copy link
Owner

baskren commented Jul 23, 2020

@Tims159

I just spent 10+ minutes updating the demo project to AndroidX to be able to build for Android 10 (PIE) and, again, ran the HTML Export page in the demo project successfully. I don't doubt what you are seeing ... it's just that there are a lot of moving parts that go into a failure. 90% of the time, if a developer does not make the effort to share with me a Reproduction Link (a demo solution), there just isn't enough information to find the root cause of the issue.

@Tims159
Copy link
Author

Tims159 commented Jul 23, 2020

Sorry, I thought its general issue, here is the demo app for issue reproduction. it only fails on device running Android 10.
forms9_issue_android10.zip

@baskren
Copy link
Owner

baskren commented Jul 23, 2020

Thanks for the demo project. With it I am able to reproduce a crash. Really scratching my head as to why I couldn't get it to crash with the Forms9Patch.Demo project.

@baskren
Copy link
Owner

baskren commented Jul 24, 2020

version 2.4.0.0 should address this issue. Again, I could not have fixed it without your demo project.

@Tims159
Copy link
Author

Tims159 commented Jul 25, 2020

Thanks. And sorry for not sharing the reproduction app in the first place.

@Tims159
Copy link
Author

Tims159 commented Jul 25, 2020

Just tried the new update. The generated pdf file name is appended with 23 digit nuber and '.' is missing before pdf. So it is not geetting associated with pdf application.
Will try on actual Pixel by Monday.

@baskren
Copy link
Owner

baskren commented Jul 25, 2020

@Tims159 -

Thanks for letting me know.

  • My fault on missing the . between the filename and the suffix. Thank you for letting me know.
  • I'm backed into a corner on the 23 digit number - blame Android on this one. It's an artifact of Java.IO.File.CreateTempFile - which I didn't notice until you pointed it out to me. CreateTempFile appears to be the only approach to write a file, have it accessible to sharing, etc., AND not require user intervention (as would be the case with Android's Scoped Storage). More here if you're interested.

@baskren
Copy link
Owner

baskren commented Jul 25, 2020

version 2.4.2 is now available via NuGet.org

@Tims159
Copy link
Author

Tims159 commented Jul 29, 2020

Working :)
I was just wondering if normal create file can be used insted of temp file (temp file will append those 23 digits for uniqueness) in Cache space. Cause nowhere its written in Android docs that only temp file should be created in cache space (I might be wrong). Also path is anyway availabe to developer by using this Nuget, so the delete decision can left to developer.

Anyway just a suggestion. I'm closing the issue.

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