Currently we are trying to change the Multi-dex from dx to D8 but unfortunately we are getting a build error after doing this.
The build error we get is:
R8 : warning : Missing class: com.samsung.android.fingerprint.FingerprintManager$EnrollFinishListener
R8 : warning : Missing class: com.samsung.android.fingerprint.FingerprintIdentifyDialog$FingerprintListener
R8 : warning : Missing class: android.arch.paging.PositionalDataSource
R8 : warning : Missing class: com.samsung.android.fingerprint.IFingerprintClient$Stub
R8 : error : Compilation can't be completed because some library classes are missing.
104 Warning(s)
1 Error(s)
Time Elapsed 00:01:21.69
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
Because of this error I though there was something wrong with one of the libraries we are using (https://github.com/smstuebe/xamarin-fingerprint) but when I create a new Android project and only add this nuget package to the project and enable D8, I don't get the above build error.
So my question is, what could be the reason for this build error? I tried to change several settings in .csproj but none of them worked.
Note: for dx we had to add these two lines in the csproj:
<DxExtraArguments>--force-jumbo </DxExtraArguments>
<AndroidMultiDexClassListExtraArgs>--disable-annotation-resolution-workaround</AndroidMultiDexClassListExtraArgs>
Without these two lines we get the following error while building with Multi-dex (Dx)
com.android.dex.DexException: Too many classes in --main-dex-list, main dex capacity exceeded
So maybe we need a D8 equivalent for these two lines of code?
Answers
To enable the new behavior, we need to introduce the property in csproj file.
$(AndroidDexTool)
- supportsdx
orr8
Detailed explanation of Android’s R8 dexer:
https://devblogs.microsoft.com/xamarin/androids-d8-dexer-and-r8-shrinker/
https://github.com/xamarin/xamarin-android/blob/master/Documentation/guides/D8andR8.md#so-how-do-developers-use-it-what-are-sensible-msbuild-property-defaults
That is what I did but that results in the build error I described.
Try the following steps:
1.Add the two setting in csproj file:
2.Add library in AndroidManifest.xml:
3.Install nuget packages to add references to the missing class.
Check the link:
https://github.com/xamarin/xamarin-android/issues/2693#issuecomment-514698561
Thanks for you response @Jarvan
I am doing exactly what you described but the error doesn't disappear.
Build error:
I thought maybe it has something to do with the Plugin.Fingerprint nuget package since the missing class contains fingerprint in the package name. So what I did was creating a new empty Xamarin.Android project and added this nuget package as reference and after that I enabled the D8 Multidex in the csproj.
The result of this was that it worked. So it seems nothing to do with the Plugin.Fingerprint nuget package.
The packages we are using in our project are:
Have you tried to delete the files in obj and bin folders to rebuild the project?
Yes I did. Does not help.
Hey @StefanMobile , Have you solved it?
Facing the same issues with an other nuget (Branch SDK)
Tried all the steps you tried but getting the same problems... Is it just an immature VS integration?
@hanch , no unfortunately I haven't found a solution yet.
I am getting the exact same issue
I found a work around @StefanMobile @hauchr @Jarvan . It's about the multi-dex and the aapt2 and the Dex compiler.
I kept playing with the settings randomly until I hit this:
See image
The setting options @IanVink suggested worked for me! Thanks a lot!
worked for me, but now appears that when i run on android device.
Same here after updating VS2019 to the last version 16.5.0.
The proposed workaround is working and I'm getting a proper build after change those options, but I have another error when I try to run the app on my phone:
(It's not my first round with xamarin, and I hate every time this happens[frequently], what a loss of productivity it is)
We also get this problem
Updated to VS for Mac version 8.5 and Android app won't build now. Reference to Java.Interop is missing. Thanks for any help!
https://stackoverflow.com/questions/60841324/java-interop-missing-after-upgrading-to-vs-for-mac-8-5
Was able to add reference to Java.Interop.dll by browsing to the file using path below. However I continue to get exact same build error as @guilloag . Were you ever able to figure out a solution? Thanks!
Macintosh HD ▸ Library ▸ Frameworks ▸ Xamarin.Android.framework ▸ Versions ▸ 9.0.0-20 ▸ lib ▸ xamarin.android ▸ xbuild-frameworks ▸ MonoAndroid ▸ v1.0
We "kinda" got it working, but it's a bit of work.
We upgraded the solution to AndroidX.
Then we took that .csproj file and pulled in all our files and then slowly and methodically added each nuget package as it was needed.
We made sure that our csproj file didn't contain any of these:-
We also got rid of our linker.xml
and the AndroidEvnironment file for mono settings
We use Aapt2 to true
Multidex is off
Anyone else do anything?
Try setting your project back to the current recommended defaults. For example, remove all of the following properties from the .csproj file via Notepad:
AndroidEnableMultiDex
AndroidDexGenerator
AndroidLinkTool
AndroidDexTool
This will let Xamarin.Android pick the current latest default values.
Wow, thank you Ian! That worked!
Worked for me to - much appreciated!
open the csproj file for android and remove the element I metnioned above, then save teh file. VS 2019 will reload the defaults for an android project
'
Just in case it helps anyone else, I followed the settings from another forum post (similar to recommendations on this post). Only worked for me though when I set Dex Compiler to d8 instead of dx.
smells like a fix is coming: https://developercommunity.visualstudio.com/content/problem/960245/compilation-cant-be-completed-because-some-library.html
Hi there, above mentioned changes fixes build issue, but now I'm not able to install .apk file in my device (android 10). here is an error