Closed pre-alpha-final closed 7 years ago
I have a Xamarin forms application that uses the Acr.UserDialogs nuget package. Now I upgraded my Android support libraries to 25.4.0.1. In Visual Studio 2017 this builds fine but my CI build in VSTS now throws this error which makes my build fail:
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Could not resolve reference to 'Android.Support.Design.Widget.BottomSheetDialog' (defined in assembly 'Acr.UserDialogs, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null') with scope 'Xamarin.Android.Support.Design, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. When the scope is different from the defining assembly, it usually means that the type is forwarded. ---> Mono.Cecil.ResolutionException: Failed to resolve Android.Support.Design.Widget.BottomSheetDialog
Same issue for me at 25.4.0.1 stable. Working fine at 25.3.1 - related issue https://github.com/aritchie/userdialogs/issues/413
Intresting, it's only a problem in releasemode. That explains why it builds in vs2017 (debug) and not in vsts (release).
For me the same - works in Debug, didn't work in Release. Maybe it somehow related to LINKER mode...
Maybe it somehow related to LINKER mode...
??? There is no mistery here. It's what i wrote in my first post:
Assembly Xamarin.Android.Support.Design is missing the BottomSheetDialog class
The class is missing from the binding library dll. It's in android support and didn't make it through the binding process. You can check this with any decompiler, even the one in VisualStudio (assembly browser).
As to why it's working only in debug. It's not actually the case of debug/release. It's just that you have linking enabled in release mode by default.
When you don't do any linking the linker doesn't touch any dlls. They're just packed with the apk as is. Then when you launch the app, the stuff you need is pulled from the dlls. So latest UserDialogs for instance use BottomSheetDialog, but you don't need it directly in Your app (because you don't use that specific dialog). BottomSheetDialog is still missing but Your app doesn't need it so it doesn't crash.
When you enable linking in either debug or release the situation is different. Every linked dll is grinded down into binary form. Everything that was in that dll needs to be available under some memory address in the binary. This means that every class/method etc. is needed. So again with UserDialogs it goes like this:
As You can see this crashes at step 2. Even though BottomSheetDialog isn't used in Your app it is needed during linking, bacause "it could" be used UserDialogs. During step 2 linker just doesn't know if it's needed or not so it requires it to be available.
Ditto here.
@Redth I made the fixes for these bugs. Could I make a pull request?
@Redth BottomSheetDialogFragment should be added too
Fixed in 25.4.0.2
Support Libraries Version (eg: 23.3.0): 25.4.0-rc1
Describe your Issue:
Assembly Xamarin.Android.Support.Design is missing the BottomSheetDialog class. The class is normally located in Android.Support.Design.Widget namespace. It was available in last nuget 25.3.1.