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

Build fails when using WorkManager and D8 #168

Open
tranb3r opened this issue Apr 30, 2019 · 26 comments
Open

Build fails when using WorkManager and D8 #168

tranb3r opened this issue Apr 30, 2019 · 26 comments

Comments

@tranb3r
Copy link

tranb3r commented Apr 30, 2019

Xamarin.Android Version (eg: 6.0):

9.3.0.14

Operating System & Version (eg: Mac OSX 10.11):

Windows 10 1809

Support Libraries Version (eg: 23.3.0):

28.0.0.1

Describe your Issue:

Enabling D8 when using Workmanager causes Build to fail.

Steps to Reproduce (with link to sample solution if possible):

Add Xamarin.Android.Arch.Work.Runtime NuGet package and use the WorkManager to enqueue some worker.
Enable D8 in android csproj (<AndroidDexTool>d8</AndroidDexTool>)
R8 or Proguard is NOT enabled.
Build fails.

You can use this sample to reproduce : https://github.com/JonDouglas/WorkManagerSample
When enabling D8, build fails.

Include any relevant Exception Stack traces, build logs, adb logs:

R8 : warning : Missing class: android.arch.paging.PositionalDataSource
R8 : error : Compilation can't be completed because some library classes are missing.

@sgong-pdftron
Copy link

Any update on this issue? I am having similar situation and trying to bind a library that is using Room, the exact same error (Missing class: android.arch.paging.PositionalDataSource) is showing up as well. And I cannot seem to find a package that contains this class. Thanks.

@sgong-pdftron
Copy link

sgong-pdftron commented Jun 5, 2019

Update: manually including the android.paging common jar (tested with common-1.0.1.jar) as EmbeddedJar in the binding library will create a successful build.

@tranb3r
Copy link
Author

tranb3r commented Jun 13, 2019

Xamarin.Firebase.JobDispatcher nuget has been removed from nuget.org.
So I guess WorkManager is now the only way to schedule a job properly.
Anybody working on a fix for this issue ? It's really becoming a blocker for me...

@tranb3r
Copy link
Author

tranb3r commented Jul 4, 2019

I've opened this ticket more than 2 months ago, and so far it's been totally ignored.
Is this component maintained ?
How are we suppose to use it if build fails when using it ?!?

@riteshdubey86
Copy link

Has someone get the solution of this problem. We are getting this error in release mode.

@tranb3r
Copy link
Author

tranb3r commented Jul 17, 2019

I've managed to find a workaround (even if I do not fully understand why it works...):

  1. Add this to your proguard.cfg
-keep public class android.arch.lifecycle.ProcessLifecycleOwnerInitializer { *; }
-keep public class androidx.work.impl.** { *; }
-dontwarn android.arch.paging.PositionalDataSource
  1. Add this to your LinkerConfig.xml
<assembly fullname="Xamarin.Android.Arch.Work.Runtime">
  <type fullname="*" />
</assembly>

@riteshdubey86, hope this helps!

@martijn-nap
Copy link

martijn-nap commented Aug 14, 2019

Same problem here. The workaround provided by @tranb3r isn't working for me.
"Compilation can't be completed because some library classes are missing."

"Proguard configuration file 'C:\Users\user.nuget\packages\xamarin.android.arch.persistence.room.runtime\1.1.1.1\build....\proguard\proguard.txt' was not found.'"

"Proguard configuration file 'C:\Users\user.nuget\packages\xamarin.android.arch.work.runtime\1.0.0\build....\proguard\proguard.txt'"

"Missing class: android.arch.paging.PositionalDataSource"

using NuGet Xamarin.Android.Arch.Work.Runtime

@diegostamigni
Copy link

@martijn-nap just add -keep public class android.arch.paging.** { *; } to your proguard cfg

@martijn-nap
Copy link

@martijn-nap just add -keep public class android.arch.paging.** { *; } to your proguard cfg

That does not (re)solve anything... Same errors still happen

@diegostamigni
Copy link

diegostamigni commented Aug 14, 2019

That's what I have and works fine to me @martijn-nap. Try adding the notwarn too, such that you end up with:

-keep class android.arch.paging.** { *; } 
-dontwarn android.arch.paging.**

@martijn-nap
Copy link

Removes the warning (ofcourse) but makes the App startup and instantly crashes. Also adds a lot of other errors...
err

@diegostamigni
Copy link

Removes the warning (ofcourse) but makes the App startup and instantly crashes. Also adds a lot of other errors...
err

It might be for other reasons tho, following is my proguard cfg I use to one of my projects where I have workers: Proguard.txt

Try it and let us know @martijn-nap

@martijn-nap
Copy link

martijn-nap commented Aug 14, 2019

Works with your file! Going to narrow it down now to see what the missing rule is.

EDIT: thanks for the help! Problem was that -keep class androidx.work.impl.** { *; } was missing.

@diegostamigni
Copy link

Yeah, you're missing something else in your proguard cfg. Afaik it should tell you if you check carefully your build log tho. After all, I've been populating my cfg from there (+ the standard Xamarin suggested ones)

@3akat
Copy link

3akat commented Aug 16, 2019

@martijn-nap @diegostamigni
Guys, can you please create a demo app where the issue is fixed with your workaround? I've tried but no success. Would really appreciate!

@tranb3r
Copy link
Author

tranb3r commented Sep 10, 2019

@Redth Any progress on this issue ?

@thudugala
Copy link

I'm getting MSB6006: "java.exe" exited with code 1.

VS: 16.3.1
Dex: D8
shrinker: R8

after setting proguard.cfg and LinkerConfig.xml

2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.D8.targets(81,5): error MSB6006: "java.exe" exited with code 1.

@Redth
Copy link
Member

Redth commented Oct 3, 2019

The proguard warnings should be fixed in:
https://www.nuget.org/packages/Xamarin.Android.Arch.Work.Runtime/1.0.0.3
(which should pull in a newer version of persistence packages with similar fixes).

Please let us know if this resolves the issue.

@Redth Redth added the needs-info More information is requested by engineering label Oct 3, 2019
@thudugala
Copy link

issue is fixed

@tranb3r
Copy link
Author

tranb3r commented Oct 7, 2019

No more warnings but I still need to add some rules to my proguard.cfg in order for it to work.

@guianm
Copy link

guianm commented Oct 10, 2019

Error persists when using R8 shrink.

@thudugala
Copy link

Getting error

2>R8 : warning : Missing class: android.arch.paging.PositionalDataSource
2>R8 : error : Compilation can't be completed because some library classes are missing.

VS: 16.3.8
Xamarin.Forms: 4.3.0.947036
Dex: D8
shrinker: R8

@clintonrocksmith
Copy link

I turned off MultiDex and it fixed it for me

@Redth Redth removed the needs-info More information is requested by engineering label Feb 10, 2020
@clintonrocksmith
Copy link

Morning, after updating to Visual Studio 16.5 we again have build issues. This is on Mac and Windows.
Using R8, I get this type of output:-
1>R8 : warning : Missing class: org.conscrypt.ConscryptHostnameVerifier
1>R8 : warning : Missing class: android.arch.paging.PositionalDataSource
1>R8 : error : Compilation can't be completed because some library classes are missing.

And when I don't, it has trouble seeing *.png for some reason

I'll do more investigation to try and figure out what is going on. We have a complex application from XF1.x so it could be anything.

@RobTF
Copy link

RobTF commented Apr 1, 2020

Hi, yes we have the same issue as of 16.5.1 and still see it on 16.5.2.

Error is;
Missing class: android.arch.paging.PositionalDataSource

Something has definitely broken, am happy to downgrade to 16.4.x temporarily if there is away to do that?

@ijunaid
Copy link

ijunaid commented Apr 21, 2020

Facing same issues after updating visual studio on Mac.

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