xamarin / AndroidSupportComponents

Xamarin bindings for Android Support libraries - For AndroidX see https://github.com/xamarin/AndroidX
MIT License
146 stars 56 forks source link

Missing BottomSheetDialog #61

Closed pre-alpha-final closed 7 years ago

pre-alpha-final commented 7 years ago

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.

michelmoorlag commented 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:

[error]C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1569,5): Error MSB4018: The "LinkAssemblies" task failed unexpectedly.

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

Szymaniuk commented 7 years ago

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

michelmoorlag commented 7 years ago

Intresting, it's only a problem in releasemode. That explains why it builds in vs2017 (debug) and not in vsts (release).

Szymaniuk commented 7 years ago

For me the same - works in Debug, didn't work in Release. Maybe it somehow related to LINKER mode...

pre-alpha-final commented 7 years ago

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:

  1. Your App uses UserDialogs, so everything from there is pulled
  2. UserDialogs use stuff from android support libraries so everything from there is pulled
  3. Stuff that isn't used is cut out from the binary

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.

BlueFire-LLC commented 7 years ago

Ditto here.

tuyen-vuduc commented 7 years ago

@Redth I made the fixes for these bugs. Could I make a pull request?

tureck1y commented 7 years ago

@Redth BottomSheetDialogFragment should be added too

Redth commented 7 years ago

Fixed in 25.4.0.2