tbaggett / xfgloss

New styling properties for standard Xamarin.Forms controls
Other
160 stars 25 forks source link

Failed to register the needed AppCompat version of the XFGloss custom renderers #19

Closed malokuS closed 6 years ago

malokuS commented 7 years ago

Hi! First of all you have an awesome project ongoing!

Tried to implement XFGloss in my current project with these properties:

Called Init() after LoadAplication() like this:


public class MainActivity : FormsAppCompatActivity
{
      protected override void OnCreate(Bundle savedInstanceState)
     {
           ...
           Forms.Init(this, savedInstanceState);
           ...
           LoadAplication(new App());

           //XFGloss Call
           XFGloss.Droid.Library.Init(this, savedInstanceState);
     }
}

But I get this error:

System.InvalidOperationException:

XFGloss.Droid.Library.Init(...) failed to register the needed AppCompat version of the XFGloss custom renderers. Please report an issue at https://github.com/tbaggett/xfgloss. at XFGloss.Droid.Library.RegisterAppCompatRenderers () [0x00081] in <954620044cfa49a0ab8663158f33db77>:0 at XFGloss.Droid.Library.Init (Android.Content.Context context, Android.OS.Bundle bundle) [0x0001f] in <954620044cfa49a0ab8663158f33db77>:0 at MyApp.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0014d] in /Users/me/Projects/MyApp/Droid/Activities/MainActivity.cs:92 at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_osBundle (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <7e083afc7c9045f59e01d9c14931060d>:0 at at (wrapper dynamic-method) System.Object:28916aee-0aa7-4db0-90a4-e61bc00c845d (intptr,intptr,intptr)

Any resolution?

mrka124 commented 7 years ago

Same issues

tbaggett commented 7 years ago

Sorry for the slow reply on this issue. I will fix this and other outstanding issues in a couple of weeks when I complete my current project.

malokuS commented 7 years ago

@tbaggett take your time as for right now I have paused the implementation of XFGloss. Would love to hear back when this gets fixed 😄

leotx commented 7 years ago

+1

ojhariddhish commented 7 years ago

Are there any fixes or workarounds for this issue?

This library is awesome, keep up the good work!

deathwind commented 7 years ago

+1 this library is very useful , but I have same exception:(

ydniw commented 7 years ago

@tbaggett Any news on this, i have the same error. Appreciate looking into this. Thanks.

tbaggett commented 7 years ago

Hi all, again, apologies that I haven't had time to investigate this. I'm wrapping up a 6 month contract this week, so I will have time to look into this and other requests next week.

tungchau commented 7 years ago

Just remove the Init line (Xamarin 2.3.4.270): //XFGloss.Droid.Library.Init(this, savedInstanceState);

jerone commented 6 years ago

We got the same issue for a specific device: Galaxy J1 Ace, Android 5.1, armeabi-v7a.

Click to show logcat log... ``` 10-31 04:28:52.630: I/MonoDroid(9651): UNHANDLED EXCEPTION: 10-31 04:28:52.650: W/Conscrypt(6077): Could not set socket write timeout: 10-31 04:28:52.660: W/Conscrypt(6077): java.lang.reflect.Method.invoke(Native Method) 10-31 04:28:52.660: W/Conscrypt(6077): java.lang.reflect.Method.invoke(Method.java:372) 10-31 04:28:52.680: D/ActivityManager(723): caller:android.app.ApplicationThreadProxy@33f23557, r.packageName :com.app.dummy 10-31 04:28:52.710: I/MonoDroid(9651): System.InvalidOperationException: XFGloss.Droid.Library.Init(...) failed to register the needed AppCompat version of the XFGloss custom renderers. Please report an issue at https://github.com/tbaggett/xfgloss. 10-31 04:28:52.710: I/MonoDroid(9651): at XFGloss.Droid.Library.RegisterAppCompatRenderers () [0x00081] in <954620044cfa49a0ab8663158f33db77>:0 10-31 04:28:52.710: I/MonoDroid(9651): at XFGloss.Droid.Library.Init (Android.Content.Context context, Android.OS.Bundle bundle) [0x0001f] in <954620044cfa49a0ab8663158f33db77>:0 10-31 04:28:52.710: I/MonoDroid(9651): at PanelApp.Droid.MainActivity+d__0.MoveNext () [0x000f2] in <1971596d0ccd416ab4d10bd810f65715>:0 10-31 04:28:52.710: I/MonoDroid(9651): --- End of stack trace from previous location where exception was thrown --- 10-31 04:28:52.710: I/MonoDroid(9651): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0 10-31 04:28:52.710: I/MonoDroid(9651): at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in :0 10-31 04:28:52.710: I/MonoDroid(9651): at Android.App.SyncContext+<>c__DisplayClass2_0.b__0 () [0x00000] in <22be559557d641beaea0e4d52495c5aa>:0 10-31 04:28:52.710: I/MonoDroid(9651): at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <22be559557d641beaea0e4d52495c5aa>:0 10-31 04:28:52.710: I/MonoDroid(9651): at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <22be559557d641beaea0e4d52495c5aa>:0 10-31 04:28:52.710: I/MonoDroid(9651): at (wrapper dynamic-method) System.Object:10d9d29f-cba1-4aee-8203-5f600273c047 (intptr,intptr) 10-31 04:28:52.730: W/art(9651): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable 10-31 04:28:52.750: W/Conscrypt(6077): Could not set socket write timeout: 10-31 04:28:52.770: W/Conscrypt(6077): java.lang.reflect.Method.invoke(Native Method) 10-31 04:28:52.770: W/Conscrypt(6077): java.lang.reflect.Method.invoke(Method.java:372) 10-31 04:28:52.840: W/InputDispatcher(723): channel ~ Consumer closed input channel or an error occurred. events=0x9 10-31 04:28:52.840: E/InputDispatcher(723): channel ~ Channel is unrecoverably broken and will be disposed! 10-31 04:28:52.840: I/WindowState(723): WIN DEATH: Window{21654c7b u0 d0 com.app.dummy/md56267c4915024c5fb2ba3faff1c61a2c8.MainActivity} 10-31 04:28:52.840: D/PowerManagerService(723): [api] handleWakeLockDeath : release WakeLock : PARTIAL_WAKE_LOCK 'wake:com.app.dummy/md56267c4915024c5fb2ba3faff1c61a2c8.TokenRefreshService' (uid=10122, pid=9651, ws=null) (elapsedTime=8051) 10-31 04:28:52.840: D/PowerManagerService(723): [api] handleWakeLockDeath : release WakeLock : PARTIAL_WAKE_LOCK 'wake:com.app.dummy/md56267c4915024c5fb2ba3faff1c61a2c8.TokenRefreshService' (uid=10122, pid=9651, ws=null) (elapsedTime=160) 10-31 04:28:52.840: I/ActivityManager(723): Process com.app.dummy (pid 9651)(adj 0) has died(43,286) ```


Would be great if there is a fix for this.

jerone commented 6 years ago

Today I got this on another device too: Lenovo A536, Android 4.4.2. With XF 2.5.0.91635 & Xamarin.Android.Support.* 26.1.0.1.

@tbaggett Any time to have a look at this yet? Appreciate it.

ndastur commented 6 years ago

Hi. Today I got this with a Samsung S5 running API19 XF 2.5.0

Demarik commented 6 years ago

My workarounds for this issue:

try
{
  XFGloss.Droid.Library.Init(this, bundle);
}
catch (Exception e)
{
var assembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(a => a.FullName.StartsWith("Xamarin.Forms.Core", StringComparison.InvariantCultureIgnoreCase));
var registrarType = assembly.GetType("Xamarin.Forms.Internals.Registrar") ?? assembly.GetType("Xamarin.Forms.Registrar");
var registrarProperty = registrarType.GetProperty("Registered", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public);
var registrar = registrarProperty.GetValue(registrarType, null);
var registerMethod = registrar.GetType().GetRuntimeMethod("Register", new[] { typeof(Type), typeof(Type) });
registerMethod.Invoke(registrar, new object[] { typeof(Xamarin.Forms.Switch),
typeof(XFGloss.Droid.Renderers.XFGlossSwitchCompatRenderer) });
}
tbaggett commented 6 years ago

Hi all, please try the newly-released 1.1.0 version of XFGloss and let me know if it resolves this issue. It adds support for Netstandard 2.0 and Xamarin.Forms 2.5. Thanks!

tbaggett commented 6 years ago

FYI, it has been confirmed this issue still exists with the new version in issue #23. I will investigate further..

tbaggett commented 6 years ago

Thanks to @Demarik 's suggested workaround, I hopefully have a fix! I found a device that I could reproduce the issue on. I modified the code to attempt my original approach first, then attempt their workaround. The workaround took care of the issue on that device. Version 1.1.1 coming in a bit.

tbaggett commented 6 years ago

Version 1.1.1.83 is released. It should be available on nuget.org as soon as their caching catches up. Please give it a try to see if it resolves this issue. Thanks again to @Demarik for their fix!