I'm trying to make mono android simple “hello world”, but I don’t see the hello world emulator in the world?

I uninstalled android and reinstalled it in c: \ androidSdktools without spaces. So, now the emulator is working, I see the emulator.

But I tried some “hello world” text codes, and when I launch the application and start the emulator, I see the Android emulator, but I do not see wnyhere “hello world”. I'm not sure that I didn’t do anything good, or maybe because I still get an error when exiting the emulator and stop debugging, getting an error message: deploy erros. If I say yes, he will ask me to rebuild / create my solution before starting / debugging it, but this did not solve this error.

I don’t know if this error is due to the fact that I don’t see any “hello world” in the Android emulator.

I tried to make this code now:

using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; namespace MonoAndroidApplication1 { [Activity(Label = "MonoAndroidApplication1", MainLauncher = true, Icon = "@drawable/icon")] public class Activity1 : Activity { int count = 1; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button>(Resource.Id.MyButton); button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; } } } 

I have visual studio C # 2010 pro.

I tried, this is an automatic code created when I selected a new Android application.

But I did not see anything in the emulator. I tried adding to this code as:

 using System; using Android.App; using Android.Content; using Android.Runtime; using Android.Views; using Android.Widget; using Android.OS; namespace MonoAndroidApplication1 { [Activity(Label = "MonoAndroidApplication1", MainLauncher = true, Icon = "@drawable/icon")] public class Activity1 : Activity { int count = 1; TextView tv; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); tv = new TextView(this); tv.Text = "hello world"; SetContentView(tv); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button>(Resource.Id.MyButton); button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); }; } } } 

And again, I didn’t see anything in the emulator when launching any text “hello world”, and deployment errors still occur when I exit the emulator and stop debugging / launching the application. The emulator now works fine, but still gets these errors on exit.

And why do not I see the text "hello world" in the emulator?

Thanks.

+4
source share
4 answers

As soon as you change the layout by calling SetContentView a second time, there is no longer a button in the layout so that your FindViewById returns null. Then you try to set the event to a null reference.

See how to read the error log so you can find the errors:

http://android.xamarin.com/Documentation/Guides/Android_Debug_Log

+3
source

You may also not have chosen an executable instance of the emulator, as I explained here . Following this along with the instructions and the Hello World tutorial for Monodroid worked fine for me.

+1
source

You probably haven’t connected the emulator correctly.

Instead of pressing F5 so that the visual studio automatically connects the emulator

to try:

click the "Star Android Emulator Manager" button (it’s to the right of the tooltip combo box)

after the emulator, it will be displayed in the drop-down list, if it does not work, you need to exit VS and then open it again (I will appear while your emulator is open)

Select it from the drop-down list, and then press F5

Done

+1
source

What version of Java did you install? I installed Java 7 on my second computer and found out that Monodroid does not support Java 7, which is why I only saw the emulator and the hello world application.

I think that last week or so, when I did this on my other computer, they did not release Java 7.

0
source

All Articles