Activity in library doesn't work, someone please help ?

aniruguanirugu ✭✭INMember ✭✭

I have used Winforms and WPF earlier and I am not sure if this is the right way to achieve the result I am working on.

I put my activity in a android c# library ( and create a android project. The code is not working

Java.Lang.RuntimeException: Binary XML file line #1: You must supply a layout_width attribute.

[Activity(Label = "MainActivity", MainLauncher = true)] public class MainActivity : Activity { protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MainActivity); // Create your application here } }

`<?xml version="1.0" encoding="utf-8"?>


Someone please tell me what is going wrong in my code. I read on that I need to register my acitivity in mainfest. If I need to do that how I can do it in xamarin. If I am wrong please help me to use activity and code from a library.

@TechieRathore @JamesMontemagno @PierceBoggan



  • knottydevknottydev ✭✭ USMember ✭✭

    Why are you tagging user names on your post? Do you know these people? Seems rude if not...

    Does the layout referenced here exist in your project? SetContentView(Resource.Layout.MainActivity);

    If you have WPF experience and you are new to Xamarin, i would recommend a Forms PCL project project, not an Android project. I would start here:

    You'll find Forms very familiar to what you're used to in WPF, while simultaneously getting exposure / an education on mobile app dev in general.

  • aniruguanirugu ✭✭ INMember ✭✭

    Actually layout is stored in the library itself. Should I add them in Mainfest. if yes, how?

    Is my code broken because my layout files are in the library.

Sign In or Register to comment.