您好,我爲Android使用Xamarin C#。 我試圖用ListView構建一個Widget。Xamarin Android無法綁定到服務空指針
我移植的代碼:https://github.com/Nailik/AppWidgetListView
首先我移植到本C#: https://laaptu.wordpress.com/2013/07/19/android-app-widget-with-listview/ (來源:https://github.com/laaptu/appwidget-listview/tree/appwidget-listview1)
然後我做了這個變化:https://forums.xamarin.com/discussion/16930/app-widget-with-listview
,現在我卡住了。每次我試圖將小工具添加到我的屏幕上它是隻顯示remoteviews空的觀點,並與此錯誤崩潰:
Java.Lang.RuntimeException: Unable to bind to service [email protected] 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 [email protected] 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
我希望有人能幫助我,我不知道該怎麼尋找並在此錯誤出現從。