xabre / xamarin-forms-tab-badge

Xamarin Forms bindable Tab badges for iOS, Android, UWP, MacOS and WPF
MIT License
307 stars 75 forks source link

Add support for non AppCompat android apps #40

Closed msl2000 closed 6 years ago

msl2000 commented 6 years ago

Hi

Just recently added the badge package into my project but have encountered the following errors everytime I try to build:

Severity Code Description Project File Line Suppression State Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Compat, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile? File name: 'Xamarin.Android.Support.Compat.dll' at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) in /Users/builder/data/lanes/4986/fb018c56/source/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:line 225 at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel) at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) dribl.Android

xabre commented 6 years ago

Hmm, this might be caused by the latest version of the android support libs. The latest release was built usig the latest update. Maybe I can try reverting to the minim version required by Xamarin Forms

alwydl commented 6 years ago

same issue here, even with previous versions of the plugin

xabre commented 6 years ago

Can you guys tell me what version of xamarin forms, android sdk and android support libraries you are using?

alwydl commented 6 years ago

Target Framework 6.0, Xamarin forms 2.4.0.280 Xamarin.Support.v4 and v7 23.3.0

josephca88 commented 6 years ago

Hi,

Same here, I have encountered that error when building the App. Actually my application doesn't run in AppCompat. Is there any way that this plugin will work on Non-AppCompat application?

Thanks

xabre commented 6 years ago

@josephca88 The app custom renderer was designed to look for the AppCompat View components in the toolbar. It might be possible to run in a non AppCompat app but only with a new/adjusted renderer. But is there any reason to not use AppCompat with your XF app?

josephca88 commented 6 years ago

Currently, the application that I am working on is under Xamarin.Forms v2.3.2.127. This version of XF doesn't include assembly of Xamarin.Android.Support.Compat.dll.

If you don't mind, what stable version you have that can I download without requiring that specific DLL I mentioned?

xabre commented 6 years ago

I will give it another check, but here is what I suspect:

Xamarin.Forms v2.3.2.127 has an AppCompat dependency, I think the problem is that you MainActivity does not inherit from FormsAppCompatActivity which uses the material design app compat tab layout for which the badge renderer was designed.

If there is nothing speaking against this (which there should not) you should upgrade your app to use the AppCompat. Check this guide: https://developer.xamarin.com/guides/xamarin-forms/platform-features/android/appcompat/

The badge renderer will then work with the tab layout.

josephca88 commented 6 years ago

@xabre That is one problem, the project could not be updated yet to that design. Can it be still possible without upgrading to AppCompat?

xabre commented 6 years ago

@josephca88 This would require writing a new renderer. I think it's possible, but with some extra work. i will consider it as an ehancement.

josephca88 commented 6 years ago

Thank you for considering it. Will wait for the release of it. Keep it up.

xabre commented 6 years ago

@josephca88 Try out the 2.0.0 version. Let me know if it works for you

Make sure to register the LegacyBadgedTabbedRenderer for your TabbedPage

josephca88 commented 6 years ago

@xabre

Thanks for the update. Unfortunately, I wasn't able to test it at the moment because we're in the process of updating the Xamarin.Forms version of our app. I noticed that the XF version on the latest version of your plugin seems to use 2.5x

Anyhow, I will update you once we're done the process of updating and when I have tried this plugin.

Thank you once again.

josephca88 commented 6 years ago

@xabre

I was doing a test on the update but I received this error

04-16 15:19:28.720 I/mono-stdout( 8739): Plugin.Badge: No ActionBar bit ha tab layout found. Badges not added.Plugin.Badge: No ActionBar bit ha tab layout found. Badges not added.

Any idea why this is happening?

Thanks.

josephca88 commented 6 years ago

@xabre

I got also this weird error after I click/tap one of the TabPages.

04-16 17:09:12.675 W/ResourceType(10369): No package identifier when getting name for resource number 0x000000c1 04-16 17:09:12.676 W/System.err(10369): android.content.res.Resources$NotFoundException: Unable to find resource ID #0xc1 04-16 17:09:12.676 W/System.err(10369): at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:228) 04-16 17:09:12.676 W/System.err(10369): at android.content.res.Resources.getResourceName(Resources.java:2103) 04-16 17:09:12.676 W/System.err(10369): at android.widget.EditText.setText(EditText.java:105) 04-16 17:09:12.676 W/System.err(10369): at android.widget.TextView.setText(TextView.java:4355) 04-16 17:09:12.677 W/System.err(10369): at md5b60ffeb829f638581ab2bb9b1a7f4f3f.NavigationRenderer.n_onAttachedToWindow(Native Method) 04-16 17:09:12.677 W/System.err(10369): at md5b60ffeb829f638581ab2bb9b1a7f4f3f.NavigationRenderer.onAttachedToWindow(NavigationRenderer.java:47) 04-16 17:09:12.677 W/System.err(10369): at android.view.View.dispatchAttachedToWindow(View.java:15584) 04-16 17:09:12.677 W/System.err(10369): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3079) 04-16 17:09:12.677 W/System.err(10369): at android.view.ViewGroup.addViewInner(ViewGroup.java:4622) 04-16 17:09:12.677 W/System.err(10369): at android.view.ViewGroup.addView(ViewGroup.java:4424) 04-16 17:09:12.677 W/System.err(10369): at android.view.ViewGroup.addView(ViewGroup.java:4364) 04-16 17:09:12.677 W/System.err(10369): at android.view.ViewGroup.addView(ViewGroup.java:4337) 04-16 17:09:12.677 W/System.err(10369): at mono.android.app.TabEventDispatcher.n_onTabSelected(Native Method) 04-16 17:09:12.677 W/System.err(10369): at mono.android.app.TabEventDispatcher.onTabSelected(TabEventDispatcher.java:40) 04-16 17:09:12.677 W/System.err(10369): at com.android.internal.app.WindowDecorActionBar.selectTab(WindowDecorActionBar.java:633) 04-16 17:09:12.677 W/System.err(10369): at com.android.internal.app.WindowDecorActionBar$TabImpl.select(WindowDecorActionBar.java:1255) 04-16 17:09:12.677 W/System.err(10369): at com.android.internal.widget.ScrollingTabContainerView$TabClickListener.onClick(ScrollingTabContainerView.java:573) 04-16 17:09:12.677 W/System.err(10369): at android.view.View.performClick(View.java:5675) 04-16 17:09:12.677 W/System.err(10369): at android.view.View$PerformClick.run(View.java:22649) 04-16 17:09:12.677 W/System.err(10369): at android.os.Handler.handleCallback(Handler.java:836) 04-16 17:09:12.677 W/System.err(10369): at android.os.Handler.dispatchMessage(Handler.java:103) 04-16 17:09:12.677 W/System.err(10369): at android.os.Looper.loop(Looper.java:203) 04-16 17:09:12.677 W/System.err(10369): at android.app.ActivityThread.main(ActivityThread.java:6251) 04-16 17:09:12.678 W/System.err(10369): at java.lang.reflect.Method.invoke(Native Method) 04-16 17:09:12.678 W/System.err(10369): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063) 04-16 17:09:12.678 W/System.err(10369): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924) 04-16 17:09:12.704 W/ResourceType(10369): No package identifier when getting name for resource number 0x000000c6 04-16 17:09:12.704 W/System.err(10369): android.content.res.Resources$NotFoundException: Unable to find resource ID #0xc6 04-16 17:09:12.705 W/System.err(10369): at android.content.res.ResourcesImpl.getResourceName(ResourcesImpl.java:228) 04-16 17:09:12.705 W/System.err(10369): at android.content.res.Resources.getResourceName(Resources.java:2103) 04-16 17:09:12.705 W/System.err(10369): at android.widget.EditText.setText(EditText.java:105) 04-16 17:09:12.705 W/System.err(10369): at android.widget.TextView.setText(TextView.java:4355) 04-16 17:09:12.705 W/System.err(10369): at md5b60ffeb829f638581ab2bb9b1a7f4f3f.NavigationRenderer.n_onAttachedToWindow(Native Method) 04-16 17:09:12.705 W/System.err(10369): at md5b60ffeb829f638581ab2bb9b1a7f4f3f.NavigationRenderer.onAttachedToWindow(NavigationRenderer.java:47) 04-16 17:09:12.705 W/System.err(10369): at android.view.View.dispatchAttachedToWindow(View.java:15584) 04-16 17:09:12.705 W/System.err(10369): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3079) 04-16 17:09:12.705 W/System.err(10369): at android.view.ViewGroup.addViewInner(ViewGroup.java:4622) 04-16 17:09:12.705 W/System.err(10369): at android.view.ViewGroup.addView(ViewGroup.java:4424) 04-16 17:09:12.705 W/System.err(10369): at android.view.ViewGroup.addView(ViewGroup.java:4364) 04-16 17:09:12.705 W/System.err(10369): at android.view.ViewGroup.addView(ViewGroup.java:4337) 04-16 17:09:12.705 W/System.err(10369): at mono.android.app.TabEventDispatcher.n_onTabSelected(Native Method) 04-16 17:09:12.705 W/System.err(10369): at mono.android.app.TabEventDispatcher.onTabSelected(TabEventDispatcher.java:40) 04-16 17:09:12.706 W/System.err(10369): at com.android.internal.app.WindowDecorActionBar.selectTab(WindowDecorActionBar.java:633) 04-16 17:09:12.706 W/System.err(10369): at com.android.internal.app.WindowDecorActionBar$TabImpl.select(WindowDecorActionBar.java:1255) 04-16 17:09:12.706 W/System.err(10369): at com.android.internal.widget.ScrollingTabContainerView$TabClickListener.onClick(ScrollingTabContainerView.java:573) 04-16 17:09:12.706 W/System.err(10369): at android.view.View.performClick(View.java:5675) 04-16 17:09:12.706 W/System.err(10369): at android.view.View$PerformClick.run(View.java:22649) 04-16 17:09:12.706 W/System.err(10369): at android.os.Handler.handleCallback(Handler.java:836) 04-16 17:09:12.706 W/System.err(10369): at android.os.Handler.dispatchMessage(Handler.java:103) 04-16 17:09:12.706 W/System.err(10369): at android.os.Looper.loop(Looper.java:203) 04-16 17:09:12.706 W/System.err(10369): at android.app.ActivityThread.main(ActivityThread.java:6251) 04-16 17:09:12.706 W/System.err(10369): at java.lang.reflect.Method.invoke(Native Method) 04-16 17:09:12.706 W/System.err(10369): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063) 04-16 17:09:12.706 W/System.err(10369): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)

xabre commented 6 years ago

Seems to work fine in the sample app, will close