Forum Xamarin.Android

GenerateJavaStubs task failed - Broadcast receiver

meepoumeepou FRMember ✭✭
edited May 2017 in Xamarin.Android

Edit : Ok my bad I just needed to add a public default constructor (and so I have no activity parameter) it makes perfect sense just noticied when pasting the full error


I have an issue with Broadcast receiver and I can't find anything online ...

I have 2 broadcast receiver (one that I register with code and only when my app is running, and another one that I want to register globally), but when I put the tag [BroadcastReceiver] my project fails to build with error GenerateJavaStubs task failed, any idea why ?

I tried to create a fresh empty BroadcastReceiver but as soon as I put the tag it won't build, here's an example of one of my broadcast :

[BroadcastReceiver(Enabled = true)]
public class NotifsBroadcastReceiver : BroadcastReceiver
        Activity activity;

        public NotifsBroadcastReceiver(Activity pActivity)
            activity = pActivity;

        public override void OnReceive(Context context, Intent intent)

Error : /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(3,3): Error MSB4018: The "GenerateJavaStubs" task failed unexpectedly.
System.InvalidOperationException: The type 'MyApp.Droid.NotifsBroadcastReceiver' needs to have a public default constructor.
at Xamarin.Android.Tasks.ManifestDocument.Merge (System.Collections.Generic.List1[T] subclasses, System.Collections.Generic.List1[T] selectedWhitelistAssemblies, System.String applicationClass, System.Boolean embed, System.String bundledWearApplicationName, System.Collections.Generic.IEnumerable`1[T] mergedManifestDocuments) [0x00529] in /Users/builder/data/lanes/4695/bc246455/source/xamarin-android/src/Xamarin.Android.Build.Tasks/Utilities/ManifestDocument.cs:256
at Xamarin.Android.Tasks.GenerateJavaStubs.Run (Java.Interop.Tools.Cecil.DirectoryAssemblyResolver res) [0x004bb] in /Users/builder/data/lanes/4695/bc246455/source/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:212
at Xamarin.Android.Tasks.GenerateJavaStubs.Execute () [0x00219] in /Users/builder/data/lanes/4695/bc246455/source/xamarin-android/src/Xamarin.Android.Build.Tasks/Tasks/GenerateJavaStubs.cs:87
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/msbuild-15.0/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:632
at Microsoft.Build.BackEnd.TaskBuilder+d__26.MoveNext () [0x00249] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/msbuild-15.0/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:787 (MSB4018) (MyApp.Droid)

Best Answers

  • meepoumeepou FR ✭✭
    Accepted Answer

    @mrizwan yeah thanks I figured it out on my own as you can see at the top of my post


  • meepoumeepou FRMember ✭✭
    Accepted Answer

    @mrizwan yeah thanks I figured it out on my own as you can see at the top of my post

Sign In or Register to comment.