Build Your First Android App with Visual Studio 2019 and Xamarin

July 25, 2019 posted by

>> Hi, I'm James Montemagno, a Program Manager here at Microsoft. Today, I'm going to show you
how to create your very first Android.NET mobile
application with Xamarin, and deploy it to an Android emulator, with Visual Studio 2019. So let's get started. Here I am on my Windows machine, I'm going to launch
Visual Studio 2019. The very first thing
that we're going to do is create a brand new project. Here of course, I can
clone, open a project, open a folder, we're going
to say, Create new project. This will bring us to
the brand new project dialog. Here I can go ahead and
select the language, platform, or project type. Let's go ahead and hit "Mobile". Here I have a lot of
different options for mobile app, Android app, or iOS app. We're going to build
a cross-platform mobile app using Xamarin Forms as
our user interface. We'll leave it as app one as
the default, and hit "Create". Here I have some options such as creating a master detail application, or a tabbed application. I can even add an ASP.NET
Core Web API backend, that it can easily debug locally, or deploy into Azure. Let's go ahead and create
a blank application. I can select between
adding Android or iOS, let's add both. We'll hit "Okay". This will scaffold out
my entire project, and.NET Standard library
with my shared code, and my shared user interface,
leveraging Xamarin Forms. Let's give it a few seconds. So here I have my project structure
with my.NET Standard library, with my shared backend business
logic and user interface, here with Xamarin Forms. I have my Android and iOS project. So I have all my resources, and all the libraries I need, and my main activity. This is the launch point
of my application. So I have a little bit
of setup code here, but the bulk of
my application is here inside of my main page.xaml. This is the entry point for my app. So I have a stack layout that says, "Welcome to Xamarin Forms." Now what we need to do is compile up our application and
deploy it to an emulator. So here inside my "Debug" menu, I can see that I have
my Android project does the startup, and I can launch to
the Android emulator, or create one. Now, when you install Visual Studio
2019 for the first time, there's no Android emulators. So when I hit "Debug", it will launch
a Android emulator Manager, and allow me to create
my default device. Here I can select from
different devices, and different processor types, but we'll just go ahead and go with the defaults for now
and hit "Create". This will download
any necessary files that I need, and create my Android emulator. Now that it's gone ahead and finish, let's go ahead and hit "Start". Now this will launch our Android
emulator that we just created. Now, what's great here is that, if you're already running
Hyper-V on your machine, we've extended the android emulators
to run on top of Hyper-V. So this is running on
top of it side-by-side. Now what's great here is that, once the Android emulator starts up, we should see it in
our drop-down menu. So let's give it a few seconds
to fully get set up. Now that our Android
emulator is online, we see it in our "Debug" menu. Here it is, My_device. All I have to do is hit, "Debug". Now the first time I run, Visual Studio 2019 will install all the necessary requirements
on that Android emulator, and then deploy it to our emulator. Let's give it
a few seconds to deploy. Now here we go, our application
is launched and as we can see, it says, "Welcome to Xamarin forms." Just like it says, inside of our cross-platform
Xamarin Forms XAML label, "Welcome to The Xamarin Forms." I'm going to pull debug mode, so everything that I
expect from locals, to debug breakpoints, everything
inside of Visual Studio, is there ready for development. There you have it. You just deployed your very first Android application
written in C# and.NET, using Xamarin and Visual Studio 2019. If you have any questions at all, feel free to reach out, and thanks for watching.


19 Replies to “Build Your First Android App with Visual Studio 2019 and Xamarin”

  1. Harish Kumar says:

    Hai Sir
    i known C# code as much as for developing web application.i like to interested to learn Xamarin Android application.I'm want learn how to create database and tables in sqlite . how to store the data in Sqlite
    please give a solution my queries asap…..

  2. Raja Liza says:

    I'm trying to migrate from android studio to visual studio then I realise there's no some sort of build preview of the app that we create. Too bad I really envy for vs speed and light IDE

  3. Hard Hat says:

    Big major features still missing in Xamarin like "Instant Run"

  4. Atoda So says:

    My main page says MainPage.xaml.cs , and all the code is in C#…. Looks nothing like your screen.

  5. Musleh haj says:

    i just did exactly how u show us & it comes with this error:
    Severity Code Description Project File Line Suppression State

    Error CS0246 The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?) 2019T001.Android D:XT20192019T0012019T0012019T001.AndroidMainActivity.cs 24 Active

  6. Дмитрий Слабнов says:

    I get 17 Mb .apk file with 1 activity and 1 text line… What about full-function application size?

  7. Paulo Faustino says:

    When I first saw the thumbnail I was like, damn, Sean Murray from no man's sky is now working at Microsoft 😂

  8. Billy Martin says:

    Google says we have to resubmit all of our Xamarin Forms apps with a 64 bit version by August. Can you cover this since it applies to EVERYONE. Thanks

  9. Art None says:

    and why no player live?

  10. Art None says:

    emulator dont start just fucken black screen wtf?

  11. Prapti Bhavsar says:

    which version of visual studio 2019 do I need to develop android app

  12. The D says:

    Hi developers:) When i want to create a new device, there's an error "incompatible JDK" even though i have installed the new JDK version

  13. Vladimir Melnikov says:

    Just started working with Xamarin, is it possible to start the "App1" app (not "App1.Android")? Not sure if what I'm trying to do is correct (does it make sense at all? Should a specific platform be chosen every time I'm trying to launch it?), but I'm getting an error "A project with an Output Type of Class Library cannot be started directly" when trying to launch App1.
    Is it because App1 doesn't serve as an app itself, but determines the parameters for the other platforms of the same project?

  14. Soyal says:

    app doesnt deploy
    what to do?

  15. Ahmet Bilgic says:

    Hi! in Visual Studio 2019 When I try to create new Emulator, It doesnt create anything, just keep waiting. what can I do? thanks

  16. jojan gojan says:

    how i can get xamarin on studio 2019

  17. Thami Nkwanyana says:

    I'm running a 64 bit x64, won't this cause problems? I's giving me an error if I'm using default settings.

  18. Aarna capital says:

    UWP is remove?

  19. elmansari youssef says:

    thank you , keep going mate (y)

Leave a Comment

Your email address will not be published. Required fields are marked *