In this article, we will create a simple Hello World android app using Android studio.
1: Create new Android studio project
Start Android studio by clicking it’s icon in the start menu.
Start a new Android studio project by using File -> New -> New Project
In the Application name, let’s provide “HelloWorldApp”. You can provide any other name you like, but since its our first app to display Hello World, we are calling it HelloWorldApp.
Clicking on the Next button will bring up the next window that provides options to select Target Android Devices.
2: Select Target Android Devices
In this screen, the Phone and Tablet selection would be already checked. Next, we have to choose the Minimum SDK. For now, lets use the default setting API 15: Android 4.0.3 (IceCreamSandwich) and click Next.
The next window is Add an activity to Mobile window.
3: Add Activity
This window provides choices for adding activity to our app.
An Activity is a special Java class that provides starting point for our app. It will also contain code that handles user interactions.
For this app, lets just select Blank Activity and click Next.
4: Customize Activity
The Activity Name will contain the name of the class that will contain our code. So, lets rename the Activity Name to HelloActivity.
The next field, Layout Name contains the name of the UI Layout xml file that will contain layout information for out app.
The contents of Title field will be used as the name of the app. You can keep the auto-suggested name or change it as per your requirement.
The last file, Menu Resource Name will contain the name of xml file that will contain any menu items that should appear when menu button is clicked.
Now, click Finish button. Android Studio will now create a project based on our choices in the above steps.
5. Testing the App
For testing the app, we can deploy it on an Emulator.
For this, click on the Play button in the android studio. Refer the button in the image below :
Clicking on the Play button, will bring up the Choose Emulator window as shown below :
Click OK to start the Emulator.
The emulator may take few minutes to start up. It should look like this after start up :
Sometimes, your app should just show up by default as shown in screen below :
Refer the following article for this :
Common errors and fixes
HAXM is not working and emulator runs in emulation mode
emulator: The memory needed by this AVD exceeds the max specified in your HAXM configuration.
The AVD cannot have higher memory limit than the HAXM.
In Android Studio:
Tools > Android > AVD Manager > Your Device > Pencil Icon> Show Advanced Settings > Memory and Storage > RAM > Set RAM to your preferred size.
In Control Panel:
Programs and Features > Intel Hardware Accelerated Execution Manager > Change > Set manually > Set RAM to your preferred size.
© 2016, www.topjavatutorial.com. All rights reserved. On republishing this post, you must provide link to original post