我创建了一个由 Service 构造的 BroadcastReceiver。BroadcastReceiver需要和Service交互,所以我传递this
给构造函数。添加 [BroadcastReceiver]-Attribute 并尝试编译(使用 MonoDevelop)后,我得到
D:\Programme\MSBuild\Novell\Novell.MonoDroid.Common.targets(3,3): Error MSB4018: Unerwarteter Fehler bei der GenerateJavaStubs-Aufgabe.
System.InvalidOperationException: The type 'keepass2android.TimeoutService/MyBroadcastReceiver' needs to have a public default constructor.
at Xamarin.Android.Tasks.ManifestDocument.Merge(List`1 subclasses, List`1 selectedWhitelistAssemblies, Boolean embed)
at Xamarin.Android.Tasks.GenerateJavaStubs.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) (MSB4018) (keepass2android)
为什么 Mono for Android 需要这个默认构造函数?它会使用默认构造函数创建我的 BroadcastReceiver(在这种情况下,BroadcastReceiver 将无法正常工作)吗?