In my app I am using Zebra EMDK library for integrating Barcode Scanner.
In order to Creating a common Application to run on Zebra and Non-Zebra devices I am adding this line of code in Android Manifest
<uses-library android:name="com.symbol.emdk" android:required="false" /> I have implemented this as per Zebra documentation
The issue I am facing is, when I enable R8, D8 compilation it is not building the application and I am getting the below error
R8: Error: Compilation can't be completed because some library classes are missing.
Android Build configuration of the app is

Error List

I am attaching the source code of the same for your reference in below link.
I did a bit of investigation.
Task "DetermineJavaLibrariesToCompile" (TaskId:489)
Task Parameter:
MonoPlatformJarPaths=
/Users/dean/Documents/Sandbox/Xamarin/xamarin-android/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/mono.android.jar
/Users/dean/Documents/Sandbox/Xamarin/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/java_runtime_fastdev.jar (TaskId:489)
Task Parameter:
JavaLibraries=
/Users/dean/.nuget/packages/xamarin.androidx.annotation/1.1.0/buildTransitive/monoandroid90/../../jar/androidx.annotation.annotation.jar
AndroidXSkipAndroidXMigration=true
/Users/dean/.nuget/packages/xamarin.androidx.collection/1.1.0/buildTransitive/monoandroid90/../../jar/androidx.collection.collection.jar
AndroidXSkipAndroidXMigration=true
/Users/dean/.nuget/packages/xamarin.androidx.lifecycle.common/2.2.0/buildTransitive/monoandroid90/../../jar/androidx.lifecycle.lifecycle-common.jar
AndroidXSkipAndroidXMigration=true
/Users/dean/.nuget/packages/xamarin.androidx.arch.core.common/2.1.0/buildTransitive/monoandroid90/../../jar/androidx.arch.core.core-common.jar
AndroidXSkipAndroidXMigration=true
obj/Debug/androidx/jl/2bbedeb9-4617-4e4e-b1d3-8d60e634827a.jar (TaskId:489)
Task Parameter:
LibraryProjectJars=
obj/Debug/lp/61/jl/classes.jar
obj/Debug/lp/59/jl/classes.jar
obj/Debug/lp/92/jl/classes.jar
obj/Debug/lp/66/jl/classes.jar
obj/Debug/lp/68/jl/classes.jar
obj/Debug/lp/57/jl/classes.jar
obj/Debug/lp/69/jl/classes.jar
obj/Debug/lp/58/jl/classes.jar
obj/Debug/lp/67/jl/classes.jar
obj/Debug/lp/93/jl/classes.jar
obj/Debug/lp/94/jl/classes.jar
obj/Debug/lp/60/jl/classes.jar
obj/Debug/lp/0/jl/formsviewgroup.jar
obj/Debug/lp/89/jl/classes.jar
obj/Debug/lp/73/jl/classes.jar
obj/Debug/lp/87/jl/classes.jar
obj/Debug/lp/80/jl/classes.jar
obj/Debug/lp/74/jl/classes.jar
obj/Debug/lp/1/jl/com.symbol.emdk.jar
obj/Debug/lp/75/jl/classes.jar
obj/Debug/lp/81/jl/classes.jar
obj/Debug/lp/86/jl/classes.jar
obj/Debug/lp/72/jl/classes.jar
obj/Debug/lp/88/jl/classes.jar
obj/Debug/lp/91/jl/classes.jar
obj/Debug/lp/65/jl/classes.jar
obj/Debug/lp/62/jl/classes.jar
obj/Debug/lp/63/jl/classes.jar
obj/Debug/lp/64/jl/classes.jar
obj/Debug/lp/90/jl/classes.jar
obj/Debug/lp/79/jl/classes.jar
obj/Debug/lp/83/jl/classes.jar
obj/Debug/lp/77/jl/classes.jar
obj/Debug/lp/70/jl/classes.jar
obj/Debug/lp/84/jl/classes.jar
obj/Debug/lp/85/jl/classes.jar
obj/Debug/lp/71/jl/classes.jar
obj/Debug/lp/76/jl/classes.jar
obj/Debug/lp/82/jl/classes.jar
obj/Debug/lp/78/jl/classes.jar
obj/Debug/lp/50/jl/bin/classes.jar
obj/Debug/lp/51/jl/bin/classes.jar
obj/Debug/lp/54/jl/bin/classes.jar
obj/Debug/lp/53/jl/bin/classes.jar
obj/Debug/lp/52/jl/bin/classes.jar
obj/Debug/lp/55/jl/bin/classes.jar
obj/Debug/lp/48/jl/bin/classes.jar
obj/Debug/lp/49/jl/bin/classes.jar (TaskId:489)
Task Parameter:DoNotPackageJavaLibraries=com.symbol.emdk.jar (TaskId:489)
Task Parameter:EnableInstantRun=True (TaskId:489)
JavaLibrariesToCompile: (TaskId:489)
/Users/dean/.nuget/packages/xamarin.androidx.annotation/1.1.0/buildTransitive/monoandroid90/../../jar/androidx.annotation.annotation.jar (TaskId:489)
/Users/dean/.nuget/packages/xamarin.androidx.collection/1.1.0/buildTransitive/monoandroid90/../../jar/androidx.collection.collection.jar (TaskId:489)
/Users/dean/.nuget/packages/xamarin.androidx.lifecycle.common/2.2.0/buildTransitive/monoandroid90/../../jar/androidx.lifecycle.lifecycle-common.jar (TaskId:489)
/Users/dean/.nuget/packages/xamarin.androidx.arch.core.common/2.1.0/buildTransitive/monoandroid90/../../jar/androidx.arch.core.core-common.jar (TaskId:489)
obj/Debug/androidx/jl/2bbedeb9-4617-4e4e-b1d3-8d60e634827a.jar (TaskId:489)
obj/Debug/lp/61/jl/classes.jar (TaskId:489)
obj/Debug/lp/59/jl/classes.jar (TaskId:489)
obj/Debug/lp/92/jl/classes.jar (TaskId:489)
obj/Debug/lp/66/jl/classes.jar (TaskId:489)
obj/Debug/lp/68/jl/classes.jar (TaskId:489)
obj/Debug/lp/57/jl/classes.jar (TaskId:489)
obj/Debug/lp/69/jl/classes.jar (TaskId:489)
obj/Debug/lp/58/jl/classes.jar (TaskId:489)
obj/Debug/lp/67/jl/classes.jar (TaskId:489)
obj/Debug/lp/93/jl/classes.jar (TaskId:489)
obj/Debug/lp/94/jl/classes.jar (TaskId:489)
obj/Debug/lp/60/jl/classes.jar (TaskId:489)
obj/Debug/lp/0/jl/formsviewgroup.jar (TaskId:489)
obj/Debug/lp/89/jl/classes.jar (TaskId:489)
obj/Debug/lp/73/jl/classes.jar (TaskId:489)
obj/Debug/lp/87/jl/classes.jar (TaskId:489)
obj/Debug/lp/80/jl/classes.jar (TaskId:489)
obj/Debug/lp/74/jl/classes.jar (TaskId:489)
obj/Debug/lp/75/jl/classes.jar (TaskId:489)
obj/Debug/lp/81/jl/classes.jar (TaskId:489)
obj/Debug/lp/86/jl/classes.jar (TaskId:489)
obj/Debug/lp/72/jl/classes.jar (TaskId:489)
obj/Debug/lp/88/jl/classes.jar (TaskId:489)
obj/Debug/lp/65/jl/classes.jar (TaskId:489)
obj/Debug/lp/62/jl/classes.jar (TaskId:489)
obj/Debug/lp/63/jl/classes.jar (TaskId:489)
obj/Debug/lp/64/jl/classes.jar (TaskId:489)
obj/Debug/lp/90/jl/classes.jar (TaskId:489)
obj/Debug/lp/79/jl/classes.jar (TaskId:489)
obj/Debug/lp/83/jl/classes.jar (TaskId:489)
obj/Debug/lp/77/jl/classes.jar (TaskId:489)
obj/Debug/lp/70/jl/classes.jar (TaskId:489)
obj/Debug/lp/84/jl/classes.jar (TaskId:489)
obj/Debug/lp/85/jl/classes.jar (TaskId:489)
obj/Debug/lp/71/jl/classes.jar (TaskId:489)
obj/Debug/lp/76/jl/classes.jar (TaskId:489)
obj/Debug/lp/82/jl/classes.jar (TaskId:489)
obj/Debug/lp/78/jl/classes.jar (TaskId:489)
obj/Debug/lp/50/jl/bin/classes.jar (TaskId:489)
obj/Debug/lp/51/jl/bin/classes.jar (TaskId:489)
obj/Debug/lp/54/jl/bin/classes.jar (TaskId:489)
obj/Debug/lp/53/jl/bin/classes.jar (TaskId:489)
obj/Debug/lp/52/jl/bin/classes.jar (TaskId:489)
obj/Debug/lp/55/jl/bin/classes.jar (TaskId:489)
obj/Debug/lp/48/jl/bin/classes.jar (TaskId:489)
obj/Debug/lp/49/jl/bin/classes.jar (TaskId:489)
ReferenceJavaLibraries: (TaskId:489)
obj/Debug/lp/1/jl/com.symbol.emdk.jar (TaskId:489)
Output Item(s):
_JavaLibrariesToCompile=
/Users/dean/.nuget/packages/xamarin.androidx.annotation/1.1.0/buildTransitive/monoandroid90/../../jar/androidx.annotation.annotation.jar
AndroidXSkipAndroidXMigration=true
/Users/dean/.nuget/packages/xamarin.androidx.collection/1.1.0/buildTransitive/monoandroid90/../../jar/androidx.collection.collection.jar
AndroidXSkipAndroidXMigration=true
/Users/dean/.nuget/packages/xamarin.androidx.lifecycle.common/2.2.0/buildTransitive/monoandroid90/../../jar/androidx.lifecycle.lifecycle-common.jar
AndroidXSkipAndroidXMigration=true
/Users/dean/.nuget/packages/xamarin.androidx.arch.core.common/2.1.0/buildTransitive/monoandroid90/../../jar/androidx.arch.core.core-common.jar
AndroidXSkipAndroidXMigration=true
obj/Debug/androidx/jl/2bbedeb9-4617-4e4e-b1d3-8d60e634827a.jar
obj/Debug/lp/61/jl/classes.jar
obj/Debug/lp/59/jl/classes.jar
obj/Debug/lp/92/jl/classes.jar
obj/Debug/lp/66/jl/classes.jar
obj/Debug/lp/68/jl/classes.jar
obj/Debug/lp/57/jl/classes.jar
obj/Debug/lp/69/jl/classes.jar
obj/Debug/lp/58/jl/classes.jar
obj/Debug/lp/67/jl/classes.jar
obj/Debug/lp/93/jl/classes.jar
obj/Debug/lp/94/jl/classes.jar
obj/Debug/lp/60/jl/classes.jar
obj/Debug/lp/0/jl/formsviewgroup.jar
obj/Debug/lp/89/jl/classes.jar
obj/Debug/lp/73/jl/classes.jar
obj/Debug/lp/87/jl/classes.jar
obj/Debug/lp/80/jl/classes.jar
obj/Debug/lp/74/jl/classes.jar
obj/Debug/lp/75/jl/classes.jar
obj/Debug/lp/81/jl/classes.jar
obj/Debug/lp/86/jl/classes.jar
obj/Debug/lp/72/jl/classes.jar
obj/Debug/lp/88/jl/classes.jar
obj/Debug/lp/65/jl/classes.jar
obj/Debug/lp/62/jl/classes.jar
obj/Debug/lp/63/jl/classes.jar
obj/Debug/lp/64/jl/classes.jar
obj/Debug/lp/90/jl/classes.jar
obj/Debug/lp/79/jl/classes.jar
obj/Debug/lp/83/jl/classes.jar
obj/Debug/lp/77/jl/classes.jar
obj/Debug/lp/70/jl/classes.jar
obj/Debug/lp/84/jl/classes.jar
obj/Debug/lp/85/jl/classes.jar
obj/Debug/lp/71/jl/classes.jar
obj/Debug/lp/76/jl/classes.jar
obj/Debug/lp/82/jl/classes.jar
obj/Debug/lp/78/jl/classes.jar
obj/Debug/lp/50/jl/bin/classes.jar
obj/Debug/lp/51/jl/bin/classes.jar
obj/Debug/lp/54/jl/bin/classes.jar
obj/Debug/lp/53/jl/bin/classes.jar
obj/Debug/lp/52/jl/bin/classes.jar
obj/Debug/lp/55/jl/bin/classes.jar
obj/Debug/lp/48/jl/bin/classes.jar
obj/Debug/lp/49/jl/bin/classes.jar (TaskId:489)
Output Item(s): _ReferenceJavaLibs=obj/Debug/lp/1/jl/com.symbol.emdk.jar (TaskId:489)
Done executing task "DetermineJavaLibrariesToCompile". (TaskId:489)
The required library is being placed in _ReferenceJavaLibs not _JavaLibrariesToCompile. It seem that _ReferenceJavaLibs is not used for the inputs to R8. Not sure if its supposed to though.
@rkshnair
This is a total hack, but try adding this
<Target Name="_Fixup" BeforeTargets="_CompileToDalvik">
<ItemGroup>
<_JavaLibrariesToCompileForApp Include="@(_ReferenceJavaLibs)" />
</ItemGroup>
</Target>
underneath the
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
in your app csproj. It seems to work around the build issue. But sure if it will cause a problem at runtime though.
If you have the EMDK jar file, you can put this in your app's project:
<AndroidExternalJavaLibrary Include="com.symbol.emdk.jar" />
Putting the file in an optional directory would also work as they mention here:
https://techdocs.zebra.com/emdk-for-android/3-1/guide/setupAndroidStudio/
But that might be an issue if you use CI/build servers.
Hello,
One of our work colleges have started getting the same issue, and all of it began with an update to VS 2019 16.5/16.5.1, so my question is what version you are using on Mac - and if it might be the same issue. If so the underlaying issue is maybe in an update of Visual studio.
Reference to my thoughts: https://developercommunity.visualstudio.com/content/problem/960245/compilation-cant-be-completed-because-some-library.html
@iXyles The reason is, from the latest VS update the R8 is enabled by default.
Cross-reference:
I have聽now added the AndroidExternalJavaLibrary workaround mentioned above to that item.
In case they might be helpful for anyone, I'll add the slightly more verbose workaround steps that I wrote up for the Developer Community item here too.
Add com.symbol.emdk.jar to the project, and set the Build Action to AndroidExternalJavaLibrary.
The com.symbol.emdk.jar file can be found by searching in the obj directory after the initial failed build. For example, in PowerShell:
Get-ChildItem -Recurse -Path obj -Filter com.symbol.emdk.jar
The ideal future fix for the R8 warnings for this specific library will be for Zebra's Symbol.XamarinEMDK NuGet package to add a custom MSBuild .targets file in the NuGet package to set up any consuming apps to use a version of the com.symbol.emdk.jar file from within the NuGet package as an item with the AndroidExternalJavaLibrary build action. That will mean consuming apps won't need to apply a workaround anymore, and it will allow the NuGet package to move away from using the [assembly: DoNotPackage] attribute, which is being deprecated starting in the Xamarin.Android 10.3 Preview (in Visual Studio 2019 version 16.6 Preview).
Same problem for me, solved removing AndroidEnableMultiDex option from csproj, waiting for a real solution from Zebra
we at Zebra Techsupport are made aware of this issue with R8 warnings and EMDK Nuget package
we have approached our Engineering EMDK team around this and will post back an message here once we have their opinion.
internally we have an Engineering ticket with refernce "SPR39963"
@xbr786 Is there any update from Zebra regarding this issue? When we can expect a new release?
Most helpful comment
we at Zebra Techsupport are made aware of this issue with R8 warnings and EMDK Nuget package
we have approached our Engineering EMDK team around this and will post back an message here once we have their opinion.
internally we have an Engineering ticket with refernce "SPR39963"