Reputation: 183
Hello i'm using Xamarin C# for Android. I tried to build a Widget with ListView.
my ported Code : https://github.com/Nailik/AppWidgetListView
First i ported this to C#: https://laaptu.wordpress.com/2013/07/19/android-app-widget-with-listview/ (source: https://github.com/laaptu/appwidget-listview/tree/appwidget-listview1)
then i made this Change: https://forums.xamarin.com/discussion/16930/app-widget-with-listview
and now i stuck. Everytime i try to add the Widget to my Screen it's only showing the remoteviews empty view and is crashing with this error:
Java.Lang.RuntimeException: Unable to bind to service md5037fca43706e0b812912372d4076c895.WidgetService@3888bf9f with Intent { dat=intent: cmp=StimeApplication.StimeApplication/md5037fca43706e0b812912372d4076c895.WidgetService (has extras) }: java.lang.NullPointerException: Attempt to invoke interface method 'void android.widget.RemoteViewsService$RemoteViewsFactory.onCreate()' on a null object reference ---> Java.Lang.NullPointerException: Attempt to invoke interface method 'void android.widget.RemoteViewsService$RemoteViewsFactory.onCreate()' on a null object reference
at --- End of managed exception stack trace ---
at java.lang.NullPointerException: Attempt to invoke interface method 'void android.widget.RemoteViewsService$RemoteViewsFactory.onCreate()' on a null object reference
at at android.widget.RemoteViewsService.onBind(RemoteViewsService.java:243)
at at android.app.ActivityThread.handleBindService(ActivityThread.java:2939)
at at android.app.ActivityThread.access$1900(ActivityThread.java:169)
at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1511)
at at android.os.Handler.dispatchMessage(Handler.java:111)
at at android.os.Looper.loop(Looper.java:194)
at at android.app.ActivityThread.main(ActivityThread.java:5552)
at at java.lang.reflect.Method.invoke(Native Method)
at at java.lang.reflect.Method.invoke(Method.java:372)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
--- End of inner exception stack trace ---
at --- End of managed exception stack trace ---
at java.lang.RuntimeException: Unable to bind to service md5037fca43706e0b812912372d4076c895.WidgetService@3888bf9f with Intent { dat=intent: cmp=StimeApplication.StimeApplication/md5037fca43706e0b812912372d4076c895.WidgetService (has extras) }: java.lang.NullPointerException: Attempt to invoke interface method 'void android.widget.RemoteViewsService$RemoteViewsFactory.onCreate()' on a null object reference
at at android.app.ActivityThread.handleBindService(ActivityThread.java:2952)
at at android.app.ActivityThread.access$1900(ActivityThread.java:169)
at at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1511)
at at android.os.Handler.dispatchMessage(Handler.java:111)
at at android.os.Looper.loop(Looper.java:194)
at at android.app.ActivityThread.main(ActivityThread.java:5552)
at at java.lang.reflect.Method.invoke(Native Method)
at at java.lang.reflect.Method.invoke(Method.java:372)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
at Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void android.widget.RemoteViewsService$RemoteViewsFactory.onCreate()' on a null object reference
at at android.widget.RemoteViewsService.onBind(RemoteViewsService.java:243)
at at android.app.ActivityThread.handleBindService(ActivityThread.java:2939)
at ... 9 more
I hope someone can help me, i have no idea what to search and where this error Comes from.
Upvotes: 0
Views: 512
Reputation: 183
Fixed it after several hours of searching. Answer: "You have to inherit from Java.Lang.Object and remove the Handle and Dispose methods." From https://forums.xamarin.com/discussion/8506/crash-from-native-handle I also updatet my git respority so feel free to use this.
Upvotes: 5