Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Unable to start activity, Java.lang.IllegalArgumentException: No view found for id

salisali USMember
edited February 2017 in Xamarin.Android


protected override void OnCreate(Bundle bundle)

        addressText = FindViewById<TextView>(Resource.Id.address_text);

        locationText = FindViewById<TextView>(Resource.Id.location_text);

        barcodeText = FindViewById<TextView>(Resource.Id.Barcode);

        Button scanButton = FindViewById<Button>(Resource.Id.btnScan);

        Button buttonSend = FindViewById<Button>(Resource.Id.btnSend);

        buttonSend.Click += buttonSendClicked;

        scanButton.Click += async (object sender, EventArgs e) =>
            var scanner = new ZXing.Mobile.MobileBarcodeScanner();

            var result = await scanner.Scan();

            if (result != null)
                Console.WriteLine("Scanned Barcode: " + result.Text);
            barcodeText.Text = result.Text;
            brcode.Barcode = barcodeText.Text;


        //Initialising the LocationManager to provide access to the system location services.
        //The LocationManager class will listen for GPS updates from the device and notify the application by way of events. 
        locationManager = (LocationManager)GetSystemService(LocationService);

        //Define a Criteria for the best location provider
        Criteria criteriaForLocationService = new Criteria
            //A constant indicating an approximate accuracy
            Accuracy = Accuracy.Coarse,
            PowerRequirement = Power.Medium

        IList<string> acceptableLocationProviders = locationManager.GetProviders(criteriaForLocationService, true);

        if (acceptableLocationProviders.Any())
            locationProvider = acceptableLocationProviders.First();
            locationProvider = String.Empty;

    private async void buttonSendClicked(object sender, EventArgs e)
        var task = SaveTodoItemAsync(brcode, false);
        await task;

main.axml file:

Error Log:

Java.Lang.RuntimeException: Unable to start activity ComponentInfo{AndroidApp.AndroidApp/md55109d95aac470e32f9a4031a908f0227.ZxingActivity}:
java.lang.IllegalArgumentException: No view found for id 0x7f050005 (AndroidApp.AndroidApp:id/btnSend)
for fragment ZXingScannerFragment{3367bb0 #0 id=0x7f050005 ZXINGFRAGMENT}

I have spent more than 3 hours on this thing and no solution yet. Can anyone figure it out, please?

Sign In or Register to comment.