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

Update to AndroidX #72

Closed
PureWeen opened this issue Feb 14, 2020 · 10 comments
Closed

Update to AndroidX #72

PureWeen opened this issue Feb 14, 2020 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@PureWeen
Copy link

Is your feature request related to a problem? Please describe.
Hello from the Xamarin.Forms Team!!

Just wanted to drop an FYI here that we've updated our 4.5 release to work with AndroidX.

There have been some issues with libraries that depend on Xamarin.Android.Arch.Work.Runtime
xamarin/Xamarin.Forms#9546 (comment)

Describe the solution you'd like
Provide MonoAndroid10.0 targets that use androidx

Ping me if you have any issues or questions

@PureWeen PureWeen added the enhancement New feature or request label Feb 14, 2020
@thudugala
Copy link
Owner

@PureWeen I'm getting Missing class error When Code Shrinker is set to R8. Can you help ?

Missing class: androidx.paging.PositionalDataSource LocalNotification.Sample.Android C:\Users\elvin\source\repos\Plugin.LocalNotification\Sample\Direct\LocalNotification.Sample.Android\R8

image

image

@thudugala thudugala self-assigned this Feb 16, 2020
@PureWeen
Copy link
Author

PureWeen commented Feb 19, 2020

@thudugala I think you can fix that with a proguard file
https://github.com/xamarin/Xamarin.Forms/blob/master/.nuspec/proguard.cfg

We have one that we add in as part of our targets
https://github.com/xamarin/Xamarin.Forms/blob/master/.nuspec/Xamarin.Forms.targets#L172

I'm also poking the AndroidX team see if they have any additional thoughts

@moljac
Copy link

moljac commented Feb 20, 2020

@thudugala

Proguard file might help, but repro sample would help me a lot. Can you provide one, please?

@thudugala
Copy link
Owner

@thudugala
Copy link
Owner

@PureWeen as https://www.nuget.org/packages/Xamarin.AndroidX.Work.Runtime/ already has a proguard file. I'm not sure what I need to add more. Can you Help ?

FYI:
It seems, when I the directly reference Xamarin.AndroidX.Work.Runtime in my android project and plugin source is directly referenced. It works.
https://github.com/thudugala/Plugin.LocalNotification/tree/master/Sample/Direct

But when plugin is reference from nuget package with direct reference to Xamarin.AndroidX.Work.Runtime in my android project. It does not work.
https://github.com/thudugala/Plugin.LocalNotification/tree/master/Sample/NuGet

@PureWeen
Copy link
Author

@thudugala if you add a proguard file to your android project that keeps androidx.paging.PositionalDataSource does it work?

So if you add a proguard file with

-keep class androidx.paging.PositionalDataSource { *; }

does that work?

FYI on windows
https://docs.microsoft.com/en-us/xamarin/android/deploy-test/release-prep/proguard?tabs=windows#troubleshooting

@thudugala
Copy link
Owner

@GitBOUF
Copy link
Contributor

GitBOUF commented Mar 18, 2020

Redirect from #58

HI! Does anyone has a solution or a workaround for this problem? Getting the same error in release mode, with code shrinker set to R8 and with Plugin.LocalNotification version 5.0.0 or 5.0.1.
More specifically, the following class is missing: androidx.paging.PositionalDataSource

EDIT: Only way I've found to compile was by adding the following to proguard.cfg:
-keep class androidx.paging.PositionalDataSource { *; }
-dontwarn androidx.paging.PositionalDataSource
But it crashes the app instantly on launch, so not a workaround sadly

@GitBOUF
Copy link
Contributor

GitBOUF commented Mar 18, 2020

Found a workaround, seems like adding the following to proguard.cfg solved the problem in my case:
-keep public class androidx.work.impl.** { *; }
-keep public class androidx.paging.PositionalDataSource { *; }
-dontwarn androidx.paging.PositionalDataSource

My app compile with R8 linker, and the notifications work.

@GitBOUF
Copy link
Contributor

GitBOUF commented Mar 26, 2020

Updating the following nugets to these version:

  • Xamarin.AndroidX.Work.Runtime Version=2.3.3
  • Xamarin.AndroidX.Core Version=1.2.0

and adding the following to my proguard.cfg (ignore my previous comments):

  • -keep public class androidx.work.impl.WorkManagerInitializer

fixed the issue for me. I'm able to link in release mode with code shrinker set to R8.

If you still experience some issues, here's my complete proguard.cfg:

-keep public class androidx.work.impl.WorkManagerInitializer
-keep public class androidx.appcompat.widget.FitWindowsFrameLayout
-keep public class androidx.appcompat.widget.FitWindowsLinearLayout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants