dewango / BottomNavigationBarXF

Bottom Navigation Bar for Xamarin Forms
MIT License
187 stars 97 forks source link

New PCL project, can't build #29

Open 503geek opened 7 years ago

503geek commented 7 years ago

Error is:

1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1410,2): error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'BottomBar.XamarinForms, Version=1.0.6133.37691, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1410,2): error : File name: 'BottomBar.XamarinForms.dll'
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1410,2): error :    at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1410,2): error :    at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
1>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1410,2): error :    at Xamarin.Android.Tasks.ResolveAssemblies.Execute()

This is a brand new PCL project - BottomBar 1.1.2 is installed. If I remove BottomNavigationBarXF it can build/run again, as soon as I add BarXF back in I get the above error when building. Have tried it numerous times with with fresh PCL projects. Have tried BottomNavigationBarXF 1.0.0, same error.

<packages>
  <package id="BottomNavigationBar" version="1.1.2" targetFramework="monoandroid60" />
  <package id="Newtonsoft.Json" version="8.0.3" targetFramework="monoandroid60" />
  <package id="ThriveGmbH.BottomNavigationBar.XF" version="1.0.1" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.Design" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v4" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.AppCompat" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.CardView" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.MediaRouter" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.v7.RecyclerView" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Android.Support.Vector.Drawable" version="23.3.0" targetFramework="monoandroid60" />
  <package id="Xamarin.Forms" version="2.3.3.180" targetFramework="monoandroid60" />
</packages>
nosmirck commented 7 years ago

I have the same exact problem, could you find a workaround?

503geek commented 7 years ago

No I haven't. I'm guessing that the underlying issue may be the fact that you can't install the package at the PCL root (it will install to Project.xyz.Droid but not Project.xyz) due to this error:

Could not install package 'ThriveGmbH.BottomNavigationBar.XF 1.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

503geek commented 7 years ago

I thought to try installing only BottomNavigationBar 1.1.2 in the root PCL and that throws a similar error: Could not install package 'Xamarin.Android.Support.v4 23.3.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

So my guess is that neither package is up to date with the latest Xamarin PCL packages. I don't know how to fix that - there is a fork of this project that is more recent and I'm planning to try to get that installed at some point but probably not today https://github.com/mikescandy/BottomNavigationBarXF/commits/master his recent commits look like they are related to this bug.

nosmirck commented 7 years ago

Awesome! Do you have any idea how I can install his branch? I have no idea D:

503geek commented 7 years ago

No I haven't gotten that far yet. If you look at the other repository it contains a solution and nuget.exe - from what I've gathered it might be possible to create a nupkg from that code. I'm guessing it's simpler than that but I haven't figured it out either.

nosmirck commented 7 years ago

Ok, well, Ifirst just downloaded the whole project from that guy, it includes an example, it works perfectly.

Then, I figured what he changed and all he did was to change the PCL target profile to use 259 (which is the default from some recent xamarin versions) from 78 (the one used by the original plugin) and I found this: http://danrigby.com/2014/04/16/xamarin-pcl-profile-notes/

And I managed to get my PCL project to be profile 78, first you need to uninstall every nuget package, close the project, reopen, install xamarin forms 2.3.2.127, then install the BottomNavigationBarXF plugin from nuget and everything seems to go perfect, everything installs without errors.

The thing now is that when you create a tabbed page, put some pages there and run the project, you don't get the page in the bottom, it's like nothing changed.

I haven't been able to install the updated version from Michele (mikescandy repo) because I don't know how to install the nuget from local folder.

So, I wanted to dig a bit more, I downloaded this repo and opened the example project, works as expected. I then tried to see the TabbedPage definition from there and compare to the one I have in my project and it's not the same, this one implements some interfaces that are not part of my xamarin forms.

So, that's it, I'm gone for now, but I'll get back to this issue in a couple of days, I wanted to share this with you to see if you come to an idea or something that can help.

503geek commented 7 years ago

I worked out how to do it with adding the latest fork's nuget - but, I think there is an easier and cleaner way. Basically, you're not getting dependency management if you make your own nuget package from a fork (since any attempt to update/downgrade that package won't work). So adding the dlls from the fork makes more sense. Building the solution in release mode gives you the right dlls under the project bin/ dir.

You want to add BottomBar.XamarinForms.dll to the PCL and iOS projects (I haven't tested it under iOS btw, and I probably won't test it for a couple more days since I'm focusing on Android right now). For Android you want three dlls, BottomBar.Droid, BottomBar.XamarinForms and BottomNavigationBar. I haven't tested this approach 100% yet - there's an XML file, BottomNavigationBar.xml that looks like it would be required, I'm trying to just copy it to the same path as BottomNavigationBar.dll and hopefully that'll work, if it doesn't I'll write another comment with the procedure for building a nupkg (which I have tested and it is working, it's just a lot of steps and somewhat pointless for the reasons I mentioned above about nuget - another problem is that Visual/Xamarin Studio aren't able to download the nuget for other d devs since it only exists on your local machine, which is again, another violation of dependency management)

tuneis commented 7 years ago

This is what worked for me.

I updated to the most recent version of Xamarin Forms. (2.3.3.193)

If you have BottomNavigationBar and ThriveGmbH.BottomNavigationBar.XF installed remove them first and clean your directory.

Then, in this order:

  1. Install BottomNavigationbar v1.4.0.3 only to android project.
  2. Install ThriveGmbH.BottomNavigationBar.XF v1.0.1 also only to android project.
  3. In your PCL project add a reference to BottomBar.XamarinForms.dll which should be located in your packages folder C:\\packages\ThriveGmbH.BottomNavigationBar.XF.1.0.1\lib\portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10\BottomBar.XamarinForms.dll".

To Test use the following code (not sure if this is going to be formatted correctly or not): public class TestPage : BottomBarPage { public TestPage() { Children.Add(new ContentPage() { Content = new Label { Text = "Page 1", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }, Title = "Page 1" }); Children.Add(new ContentPage() { Content = new Label { Text = "Page 2", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }, Title = "Page 2" }); Children.Add(new ContentPage() { Content = new Label { Text = "Page 3", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }, Title = "Page 3" }); NavigationPage.SetHasNavigationBar(this, true); ToolbarItems.Add(new ToolbarItem() { Text = "Something" }); } }

This works on Android. I'm not sure about iOS as I do not have a Mac to test with.

Mxrck commented 7 years ago

@tuneis Tested on iOS, only need to add the reference dll to the iOS project.

Thanks for your solution, it works like a charm

bruce-willis commented 7 years ago

@tuneis variant works, but much better install BottomNavigationbar v1.4.0.2 instead of v1.4.0.3 to prevent a lot of warnings caused by different android.support version. Read release note for 1.4.0.3 version.