- Home
- Forum
- Xamarin.Forms
- BUG: SfPdfViewer cannot use Material Design
BUG: SfPdfViewer cannot use Material Design
I am in the process of updating my project to the latest Xamarin Forms/AndroidX and have hit a weird issue. We are using Material design, so we have the ContentPage set in the Styles for the app to have:
<Style x:Key="contentPageBase" TargetType="ContentPage"> <Setter Property="BackgroundColor" Value="..."/> <!-- this uses out theme engine, I can't include that code--> <Setter Property="Visual" Value="Material"/> </Style> <Style BasedOn="{StaticResource contentPageBase}" ApplyToDerivedTypes="True" TargetType="ContentPage"/>
When the ContentPage that contains our SfPdfViewer is shown, rather than getting a page, we get nothing at all - and the app logs the following error:
Accessing hidden field Landroid/widget/TextView;->mCursorDrawableRes:I (greylist-max-p, reflection, denied)
This is Xamarin Forms 4.8.0.1560 and Syncfusion.Xamarin.SfPdfViewer 18.3.0.38.
If I override the Visual on the ContentPage and set:
Visual="Default"
The page opens as expected.
It seems that the SfPdfViewer is somehow using a private API that was deprecated on to the greylist and is only supported up to Android P. Any ideas?
To recreate this, I would think you would create an app with Xamarin Forms 4.8.0.1560, Xamarin Forms Visual Material 4.8.0.1560, Syncfusion.Xamarin.SfPdfViewer 18.3.0.38. You would create a ContentPage that had a button bound to a Command, that Command would create a ContentPage that contains a SfPdfViewer and bunds the PDF to the InputFileStream. Run this and check it works.
You need to then add the attribute Visual="Material" to the ContentPage containing the SfPdfViewer. When you now run the app, you seem to get:
Accessing hidden field Landroid/widget/TextView;->mCursorDrawableRes:I (greylist-max-p, reflection, denied)
No page will open. This should happen even if you don't bind the control to the PDF.
SIGN IN To post a reply.
7 Replies
1 reply marked as answer
ME
Matthew Emson
November 2, 2020 10:32 PM UTC
Just to reply to myself - the error we are seeing is to do with reflection in Java it seems. I think that the mCursorDrawableRes:I is being accessed when applying the new Visual value, and according to Google's docs (https://developer.android.com/about/versions/10/non-sdk-q), this is no longer supported.
Landroid/widget/TextView;->mCursorDrawableRes:I # Use the new get/setTextCursorDrawable
SP
Satheesh Palanisamy
Syncfusion Team
November 3, 2020 03:44 PM UTC
Hi Matthew,
Greetings from Syncfusion support,
We were unable to reproduce the reported issue on our end. Please find the sample in the below link, which we have created to reproduce the issue.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/GettingStartedMaterial-1272574231
kindly share the details below to provide the solution at earliest
1. Create / Modify the existing sample.
2. Android device model.
Regards,
Satheesh Palanisamy.
ME
Matthew Emson
November 3, 2020 04:51 PM UTC
Okay - here is a project that fails. You have 2 buttons on the MainPage. The top button (Open with visual default) will correctly open the PDF file. The second button does nothing. It will generate the error above in the logs.
Android is Q (version 10). We are targeting AndroidX, so you'll see the Xamarin.AndroidX.Migration is installed (you probably don't need it anymore, but I left it in there so that your IDE will do the migration if needed.) The device is a Google Pixel 3a. So, I think your main issue was that you were only targeting Android 9.0 (Android P) and the API that fails is still supported under Android P. I think the AndroidX migration is needed to make the API grey listing happen - it seems to have started to happen for me after we migrated at any rate.
Additional information - I was using Xamarin Forms Hot-reload to style the forms, and I get this error on the MaterialPdfViewerPage when saving:
Additional information - I was using Xamarin Forms Hot-reload to style the forms, and I get this error on the MaterialPdfViewerPage when saving:
11-03 16:40:33.543 D/Mono (21744): Assembly Ref addref Xamarin.HotReload.Forms[0x73b92cc300] -> Xamarin.Forms.Xaml[0x73bfbf9680]: 3
11-03 16:40:33.882 W/.GettingStarte(21744): Accessing hidden field Landroid/widget/TextView;->mCursorDrawableRes:I (greylist-max-p, reflection, denied)
[HotReload] (2020-11-03 16:40:39.9): INFO: Reloaded: 'ReloadChange in Views/MaterialPDFViewerPage.xaml', ignoring 3 unsupported edits:
[HotReload] (2020-11-03 16:40:39.9): INFO: In Views/MaterialPDFViewerPage.xaml:
[HotReload] (2020-11-03 16:40:39.9): INFO: No line info - No field mCursorDrawableRes in class Landroid/widget/TextView; (declaration of 'android.widget.TextView' appears in /system/framework/framework.jar!classes3.dex)
[HotReload] (2020-11-03 16:40:39.9): INFO: No line info - No field mCursorDrawableRes in class Landroid/widget/TextView; (declaration of 'android.widget.TextView' appears in /system/framework/framework.jar!classes3.dex)
[HotReload] (2020-11-03 16:40:39.9): INFO: No line info - No field mCursorDrawableRes in class Landroid/widget/TextView; (declaration of 'android.widget.TextView' appears in /system/framework/framework.jar!classes3.dex)
11-03 16:40:34.213 W/.GettingStarte(21744): Accessing hidden field Landroid/widget/TextView;->mCursorDrawableRes:I (greylist-max-p, reflection, denied)
ME
Matthew Emson
November 3, 2020 04:52 PM UTC
I'm not sure if the file uploaded so I tried again
Attachment: GettingStarted2020110316491_eb71d7b7.zip
Attachment: GettingStarted2020110316491_eb71d7b7.zip
AV
Ashokkumar Viswanathan
Syncfusion Team
November 4, 2020 01:17 PM UTC
Hi Matthew,
Thank you for providing requested details,
We are able to reproduce the issue, “Application throws error for material visual of SfPdfViewer control in Android X device“. Currently, we are validating the issue and we will update further details on November 6th ,2020.
Regards,
Ashok Kumar Viswanathan.
AV
Ashokkumar Viswanathan
Syncfusion Team
November 6, 2020 05:08 PM UTC
Hi Matthew,
We have confirmed that the issue “Application throws error for material visual of SfPdfViewer control in Android X device” is a defect and logged a defect report for this issue. The patch for this issue will be delivered on November 27th , 2020.
Please find the feedback link below,
Regards,
Ashok Kumar Viswanathan.
AV
Ashokkumar Viswanathan
Syncfusion Team
November 27, 2020 09:08 AM UTC
Hi Matthew,
We have resolved the issue ” Application throws error for material visual of SfPdfViewer control in Android X device” and the custom NuGet for the same can be downloaded from the following link
Custom NuGet :
Disclaimer:
Please note that we have created this NuGet for version 18.3.0.47 specifically to resolve the following issue(s) reported in this/the Forum 159336
Please note that we have created this NuGet for version 18.3.0.47 specifically to resolve the following issue(s) reported in this/the Forum 159336
Note : Kindly follow the steps to clear the NuGet cache and then install patched NuGet to get the issue resolved.
This fix will be included in our 2020 Volume 4 Main release which is expected to available in the month of December, 2020.
Regards,
Ashok Kumar Viswanathan.
Marked as answer
SIGN IN To post a reply.
- 7 Replies
- 3 Participants
- Marked answer
-
ME Matthew Emson
- Nov 2, 2020 10:21 PM UTC
- Nov 27, 2020 09:08 AM UTC