loading

This tutorial will teach you the basics of how to build an Android app using the Android Studio development environment. As Android devices become increasingly more common, demand for new apps will only increase. Android Studio is an easy to use (and free) development environment to learn on. It's best if one has a working knowledge of the Java programming language for this tutorial because it is the language used by Android. There won't be much code used in this tutorial, so I will assume that you know enough Java to understand or are willing to look up what you don't know. This will take roughly 30-60 minutes, depending on how quickly you are able to download and install Android Studio. After using this tutorial to create your first Android app, you'll be well on your way to a fun new hobby or possibly even a promising career in mobile development.

Step 1: Install Android Studio

  1. Go to http://developer.android.com/sdk/index.html to download Android Studio.
  2. Use the installer to install Android Studio following its instructions.

Step 2: Open a New Project

  1. Open Android Studio.
  2. Under the "Quick Start" menu, select "Start a new Android Studio project."
  3. On the "Create New Project" window that opens, name your project "HelloWorld".
  4. If you choose to, set the company name as desired*.
  5. Note where the project file location is and change it if desired.
  6. Click "Next."
  7. Make sure on that "Phone and Tablet" is the only box that is checked.
  8. If you are planning to test the app on your phone, make sure the minimum SDK is below your phone's operating system level.
  9. Click "Next."
  10. Select "Blank Activity."
  11. Click "Next."
  12. Leave all of the Activity name fields as they are.
  13. Click "Finish."

*Note: It is typical naming convention in Android projects to set the company name as some form of "example.name.here.com".

Step 3: Edit the Welcome Message in the Main Activity

  1. Navigate to the activity_main.xml tab if it is not already open.
  2. Make sure that the Design tab is open on the activity_main.xml display.
  3. Click and drag the "Hello, world!" from the upper left corner of the phone display to the center of the screen.
  4. In the project file system on the left side of the window, open the values folder.
  5. In the values folder, double-click the strings.xml file.
  6. In this file, find the line "Hello world!".
  7. After the "Hello world!" message, add "Welcome to my app!"
  8. Navigate back to the activity_main.xml tab.
  9. Make sure that your centered text now reads "Hello world! Welcome to my app!"

Step 4: Add a Button to the Main Activity

  1. Navigate to the Design tab of the activity_main.xml display.
  2. In the Palette menu to the left of the phone display, find Button (under the heading Widgets).
  3. Click and drag Button to be centered underneath your welcome message.
  4. Make sure your button is still selected.
  5. In the Properties menu (on the right side of the window), scroll down to find the field for "text."
  6. Change the text from "New Button" to "Next Page."

Step 5: Create a Second Activity

  1. At the top of the project's file system tree, right click on "app."
  2. Navigate through to New > Activity > Blank Activity.
  3. Change the name of this activity to "SecondActivity".
  4. Click "Finish."
  5. Make sure you are in the Design view of activity_second.xml.
  6. Drag the text box in the upper left of the phone display down to the center as you did on the Main Activity.
  7. With the text box still selected, find the "id" field in the Properties menu on the right, and set it to "text2".
  8. Open strings.xml again.
  9. Add a new line under "Hello world! Welcome to my app!" that reads "Welcome to the second page!".
  10. Navigate back to activity_second.xml.
  11. Select the text box again.
  12. In the Properties pane, set the "text" field to "@string/second_page".
  13. Make sure that the text box now reads "Welcome to the second page!" and is in the center of the screen in the phone display.

Step 6: Write the Button's "onClick" Method

  1. Select the MainActivity.java tab along the top of the work environment.

2. Add the following lines of code at the end of the onCreate method:

Button button = (Button) findViewById(R.id.button);

button.setOnClickListener(new View.onClickListener() {

@Override

public void onClick(View v) {

goToSecondActivity();

}

});

3. Add the following method to the bottom of the MainActivity class:

private void goToSecondActivity() {

Intent intent = new Intent(this, SecondActivity.class);

startActivity(intent);

}

4. Click the + next to import at the third line of MainActivity.java to expand the import statements.

5. Add the following to the end of the import statements if they are not already there:

import android.content.Intent;

import android.view.View;

import android.widget.TextView;

Step 7: Test the Application

  1. Click the green play symbol from the toolbar at the top of the Android Studio window.
  2. When the "Choose Device" dialog apperas (this may take a few moments), select the "Lauch emulator" option.
  3. Click OK.
  4. When the emulator opens (this too could take awhile), the app will automatically launch the app upon the virtual phone being unlocked.
  5. Make sure that all of your text displays correctly and that the button takes you to the next page.

Step 8: Up, Up, and Away!

Congrats! You've now completed your first Android application with some basic functionality. Your finished app should have a page greeting the user and a button that takes the user to a second page.

From here you have the cursory knowledge you need to go on to learn all there is to know about Android application development.

<p>with out the company details.can't we create the app??</p>
Guys I have a great idea for an app but I don't know how to build it.Help anyone? <br>my mail - kumarkushal71@gmail.com
<p>Hi! I have an idea. a Great app that will be helpful. but I don't know how to make it ( still thinking how ). this application maybe helpful to those who own medium businesses. I don't know who's the right person to discuss this.</p><p>please help me.</p><p>thank you :)</p><p>please send email. Thank you. </p><p><a href="mailto:n.rey_noya@yahoo.com" rel="nofollow">n.rey_noya@yahoo.com</a> </p>
I want app make aap for my website http://www.mloot.com, any advise?
Http:www.mloot.com
Http://mloot.com
<p>Hello, we can make an app for your website. Let me take this opportunity to introduce our company Phillearn Solutions, a software and training solutions company at an affordable cost. You can contact us at 9030973722 or phillearnsolutions@gmail.com. Kindly forward your contact your details, so that we can get in touch with you.</p>
<p><strong>Create an Android App With Android Studio</strong></p><p><a href="http://www.tricksandhacks.com/create-android-app-with-app-studio/" rel="nofollow">http://www.tricksandhacks.com/create-android-app-w...</a></p>
when i run the app i am getting string types not allowed (at 'id' with value '@+id/') error help me fix it
<p>very helpful for beginner...!! Thanks</p>
<p>Thank you for post helpful tutorial for Newcomers user for Android development and learning user.</p>
<p>Error:Failed to find target with hash string 'android-24' in: C:\Android\sdk1</p><p>&lt;a href=&quot;install.android.platform&quot;&gt;Install missing platform(s) and sync project&lt;/a&gt;</p><p>how to resolve</p>
<p><strong>How To Create An Android App With Android Studio</strong></p><p><a href="http://www.tricksandhacks.com/create-android-app-with-app-studio/" rel="nofollow">http://www.tricksandhacks.com/create-android-app-w...</a></p>
<p>i think you have to update your instructions, as the latest versions have half the stuff changed but other than that,this was brilliant</p>
<p>A clear guide to develop our own <a href="http://www.credosystemz.com/training-in-chennai/best-android-training-in-chennai/" rel="nofollow">Android App</a> with Android Studio. </p>
<p>Thnaks for your informative article.its very useful.&lt;a href=&quot;<a href="http://www.google.com/url?q=http%3A%2F%2Fwww.bestandroidtrainingchennai.in%2F&sa=D&sntz=1&usg=AFQjCNFIq7D_HTwFckyei_ZkSH3BBN-kAQ" rel="nofollow">http://www.bestandroidtrainingchennai.in/</a>&quot;&gt;Android Training in Chennai &lt;/a&gt;</p>
<p>Hi Guys,</p><p>I cant see this bit under strings:</p><ol><br><li>Add a new line under &quot;Hello world! Welcome to my app!&quot; that reads &quot;Welcome to the second page!&quot;.</ol><p>See below:</p><p>What am i doing wrong?</p>
It is very good way for app development
<p>Unable to dowmload the foolowing. Help me out</p>
<p>I already android studio installed</p>
<p>i dont't know how to devolep app please teach me</p>
<p>My Project in Running Even Android Virtual Device is pop up but my hello world screen is not shown ..... it is showing just default &quot;android&quot; over the screen ... please help me put how i can run my own project screen ... Thanks in advance</p>
<p><strong>How To Create An Android App With Android Studio</strong></p><p><a href="http://www.tricksandhacks.com/setup-eclipse-for-android-app-development/" rel="nofollow">http://www.tricksandhacks.com/setup-eclipse-for-an...</a></p>
<p>OK, sounda cool when I read about step 4: click and drag buttons?</p>
<p>1,674 MB for downloading the Android Studio...</p>
<p>I am not able to see my app in android emulator</p>
<p>my emulator doesn't open... and after open an error is VT-x and BIOS. blah ! blah ! blah ! please tell me solution to open my emulator.</p>
<p>Hey!.</p><p>On Windows, go to BIOS &gt; advanced settings &gt;</p><p>There should be an option to enable virtualization</p><p>Save and restart your system</p>
<p>i did not understand how to open the strings.xml page</p>
<p>HarshulS - the strings.xml page can be found in the following area:</p><p>&quot;project_name&quot;\app\src\main\res\values\strings.xml</p><p>To open it, just double click it in the left pane of Android Studio.</p><p>Hope this helps.</p>
<p>Opening that does not change centered text for me</p><p>I only had one line of code in there (other than &lt;resources&gt;&lt;/resources&gt; and it was &lt;string name=&quot;app_name&quot;&gt;Hello World!&lt;/string&gt;</p><p>Do I have to add the others? Because I tried that and it still didn't change the centered text.</p>
<p>you need to change the text property of this text box to @string/hello_world. In the properties, you might see 2 &quot;text&quot;s. Change the one that has a small spanner like icon. </p>
<p>I am also experiencing this problem. I think that Android Studio Projects has been updated since this tutorial was made. An excellent tutorial, just can't follow it exactaly step by step anymore. </p>
Yep, im glad to know im not the only one with this problem.
That is true - we are up to API 25 now and this this was written when 21 was the latest API. Truth be told - the ONLY time I bother with strings.xml (which still is in the same structure I mentioned above) is for things like app name or static menu bar titles. Studio will complain when you build the project and suggest that you use the strings.xml file but when you start getting into threaded apps - and dynamic labels - the strings file looses its usefullnes.
<p>Not sure what version of Andriod studio you are using but I have 2.2.2 for linux installed and had to pretty much use my own programming skills to make any of this work. :(</p>
<p>I am just getting to know how to program, I need a sample button code that open inputted URL on a default browser and also a code that display written text in a new window</p>
<p><strong>How To Create An Android App With Android Studio</strong></p><p><a href="http://www.tricksandhacks.com/create-android-app-with-app-studio/" rel="nofollow">http://www.tricksandhacks.com/create-android-app-w...</a></p>
<p>I think this is out of date. In the version of Android Studio I downloaded and installed today, there's no &quot;Blank Activity&quot; option. Also, the strings.xml file is not readily available; I had to look at another comment to see where it was. Plus the &quot;hello world&quot; string isn't in there.</p><p>When I try to run this, I'm told that android.support.design.widget doesn't exist... which is bewildering, because it automatically added that import to my Java file! Why would it do that if it doesn't exist? Apparently the solution is to edit the Gradle file, but I don't know what that is and don't feel like figuring it out now. I'm not sure if this is relevant to the tutorial but I thought I'd bring it up just in case.</p>
<p>Did you find a more up to date step-by-step guide as I'm having the same issue.</p>
<p>I am having a similar issue following the step by step guide, I think they've switched things around with the newest update. Exact same issues as <a href="https://www.instructables.com/member/teiladnam" rel="nofollow">teiladnam</a> is describing. </p>
<p>First time trying, I think the only thing I had trouble with was the fact that I had to capitalise the O in onClickListener. Other than that, perfect first tutorial.</p><p>setOnClickListener</p><p>onClickListener should be OnClickListener</p>
<p>Thank you , so much! !!</p>
https://mcent.com/app/?mcode=Q08W5K&amp;tcx=WAPP
<p>yup-yup-Yup! ,,, me too. This took me a couple hours to identify until<br> I read this comment then it fixed me right and removed the red on this.</p><p>Thanks for buttoning it up DouglasH1</p><p>Over all great instructable. I learned!</p>
<p>Thanks for this article,</p><p>I have followed all steps...</p><p>on compilation I get following errors...</p><p>error: cannot find symbol class onClickListner.</p><p>please help</p><p>Thanks</p>
https://mcent.com/app/?mcode=Q08W5K&amp;tcx=WAPP
<p>Hi there, i am trying to do a simple picture app but i keep getting tangle up . Please help. </p>
https://mcent.com/app/?mcode=Q08W5K&amp;tcx=WAPP

About This Instructable

1,144,640views

1,755favorites

License:

More by TheZachBales:How To Create An Android App With Android Studio 
Add instructable to: