First Android App & Android Studio Setup

In this tutorial, we will show you how to create a simple “hello world” Android project in Android Studio, and run it. Summary steps to develop an Android application :

1) Set Java Environment Path
2) Install Android Studio SDK
3) Create New Android Project
4) Create an Android Virtual Device (AVD)
5) Run App in Real Device using USB Debugging




Android app are developed in android studio. Along with android studio you need latest version of java in your laptop or desktop computer.You must get latest version of android studio, java environment and install on computer.

Set Java Class Path & Create New Android Project Video

Login & Download source code

download-code350-100





Set Java Environment Path

To Set class path of java environment.
GOTO -MyComputer – Property – Advance System Property – Advance – Environment variable.

Create new variable- write variable name: JAVA_HOME, 
variable value: " your_java_jdk_location"(Like C:\Program Files\Java\jdk1.8.0_25\ ).
Remember to use "\" at last. 

If you are installing Android Studio on Mac or Linux, You can download the latest version and check the instructions provided along with the downloaded file for Mac OS and Linux. This tutorial will consider that you are going to setup your environment on Windows machine having updated java jdk.

javaclasspath

Install Android Studio

let’s click on Android Studio.exe. file downloaded from android studio. Installation wizard look like below. First set java class path from mycomputer property.

Android studio installation wizard

studio2
studio5
studio9

Create New Android Project

Now click on Start on new android project for starting your first android application development. In next window it asked for application name & package name. Remember “com.example” must be change with some other name or company name. because package name include com.example can’t be publish on google play store.

createproject1

Click on Next & select minimum SDK to API 15. That means all devices having from API 15 to latest API (24) will support your app. If you select latest SDK suppose API 23 then only device having android API 23(marshmallow) & 24 can support your app. So try to create app that support more number of devices. API 15 is best choice for selecting minimum SDK. You can also select minimum SDK for other device like wear , glass, TV. If don’t have any idea leave it as it is.

createproject2

Click on next & there you can select layout type. You can also do it later during development. Layout is like frame where you will put item and show these item to your app user. Remember first of all always create one master layout that contains ActionBar, Navigator Drawer, main layout(Relative Layout , Linear Layout etc). Whenever you create new layout use this layout code as a frame & place textbox, image, button etc, in it. All company follow this type of standard process for development. For beginners select “Empty Activity ”

createproject3

Click on next & It asked for Main Activity name & Main Layout name. It is better to leave it as it is. Click “finish”. At this stage it going to be open development tool to write your first android application code.

createproject4

Now Below is main development window. Before start development you must know about few file which are most important.

1) AndroidManifest.xml
2) MainActivity.java
3) activity_main.xml
4) string.xml
5) build.gradle (Module.app)

createproject6

AndroidManifest.xml –

     For security reason Android OS always check required permission before app perform any action. This file contains all necessary permissions require for activity to perform. Permission means if you are accessing user contact number, photo gallery, location etc then you have to mansion each permission associate your action into AndroidManifest.xml file. Android introduces RunTime permission From API 23(Marshmallow) onward.
     AndroidManifest.xml also contains information about all activity classes(java.class file) you will create in your app. If you forgot to include any java.class file then the java.class file will not work any more until include in AndroidManifest.xml file.





















MainActivity.java –

     This is main java class file. Android app launch this file at first. This is entry point of an app. For security reason Android OS always check required permission before app perform any action. This file contains all necessary permissions require for activity to perform. Permission means if you are accessing user contact number, photo gallery, location etc then you have to mansion each permission associate your action into AndroidManifest.xml file. Android introduces RunTime permission From API 23(Marshmallow) onward. You can attach any layout file (activity_main.xml) to MainActivity.class file using setContentView(R.layout.activity_main);

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

activity_main.xml –

     This is main Layout file. Place you item like Textview, Button, Images etc inside layout (Relative layout, Linear Layout, GridLayout etc).
     Relative layout Relative Layout is a view group that displays child(item) views in relative positions. The position of each item can be specified as relative to sibling items (such as to the left-of or below another view) or in positions relative to the parent(main) Relative Layout area (such as aligned to the bottom, left or center).
    Linear layout In Android, LinearLayout is a common layout that arranges “item” in vertical or horizontal order, via orientation attribute. If orientation is vertical then items are arrange in below one another. If orientation is horizontal then items are arrange side by side left to right.
     Grid layout Grid Layout arrange item in 2×3 , 2×2 3×4 …etc format.

string.xml

      String.xml file contains all sentence and name used in app. If you want login form contains one username text and one password text, So the word username & password place in string.xml file Username.
Your can use this string in java code or xml file by calling R.string.String_username. Remember If you are developing app for multiple language like English and hindi,then it become very easy to handle all language using string.xml file. For two language create another string.xml file name as string.xml in value-hi folder inside RES folder.

build.gradle (Module.app)

      This gradle file store all dependency files and library files used in android app. With this file you can change our app version using versionCode 1, versionName “1.0”. Remember If you have published app on google play store & need to upload new update apk to play store, then versionCode in build.gradle (Module.app) must be increase by 1. Otherwise Google Play Store give you uploading error.

Create an Android Virtual Device (AVD)

     You can test you first app code on virtual device called Emulator using AVD. Click on AVD from Tool-Android-AVD. Create virtual device and configure device property as to latest android version. Remember Emulator require upto 2GB space. So if your system have RAM less then 4GB don’t use emulator any more, use real device only.
createproject8

Run App in Real Device using USB Debugging

      To enable your real device for app testing purpose, Go to phone setting & find “Developer option” & Enable “USB debugging”. If unable to find “Developer option” Go to “About phone” & tab 7 times on “Build Number”. It will show ” Developer option” in setting list.
      Now connect your phone with USB cable and On Android studio click on Android Monitor( Look bottom strip above window taskbar). check whether device is connect with android studio or not. If You dont find your device Drop-down list of device, Then install android USB debugging driver of your phone(Samsung, Micromax, LAVA) from google search.

Run App Code

      By default there is a textview in activty_main.xml file. Try to change text Hello World with another text(android:text=”Hello World!”). you can place another textview ,button etc and try to run this default code. To run First App, click on this icon place on android studio. Your will see app icon on your device(if using real device for debugging) & app look like as shown below after run.
createproject7
createproject10

Login & Download source code

download-code350-100

SUBSCRIBE FOR FREE ANDROID COURSE, Inbox 25 lesson & Video

* indicates required






Posted in andorid and tagged , , , , .

I Am Post Graduation (M.Tech. C.S.E) from VNIT, Nagpur. I Have Published Two Research Paper On International Journal. My Apps on Google Play Store- Sanyukt Parivar(Mp Police ), NOTOtag- Digital Chhindwara, The Tubby-VoiceRecognizer & More.
Contact me at kamal.bunkar@blueappsoftware.in

33 Comments

  1. I love your blog.. very nice colors & theme. Did you create this
    website yourself or did you hire someone to do it for you?
    Plz respond as I’m looking to create my own blog and would like to find
    out where u got this from. appreciate it

  2. Pretty great post. I just stumbled upon your weblog and wanted to say
    that I’ve truly loved browsing your blog posts.
    In any case I’ll be subscribing for your feed and I hope you write once more very soon!

  3. Hi there! This post could not be written any better!
    Reading through this post reminds me of my good old room mate!
    He always kept talking about this. I will forward this article to him.
    Fairly certain he will have a good read. Thank you for sharing!

  4. Hi there! Quick question that’s totally off topic.
    Do you know how to make your site mobile friendly?
    My weblog looks weird when browsing from my iphone4.
    I’m trying to find a template or plugin that might
    be able to fix this issue. If you have any recommendations, please share.
    Thank you!

  5. This is really attention-grabbing, You are an overly skilled blogger.
    I have joined your feed and look forward to in the hunt
    for extra of your great post. Also, I have shared your site in my social networks

  6. I’m really enjoying the theme/design of your blog.

    Do you ever run into any browser compatibility issues?

    A few of my blog audience have complained about my site not
    working correctly in Explorer but looks great in Chrome.
    Do you have any solutions to help fix this issue?

  7. I was recommended this web site by my cousin. I’m
    not sure whether this post is written by him as no one else
    know such detailed about my problem. You are wonderful!

    Thanks!

  8. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading your
    blog and I look forward to your new updates.

  9. Having read this I thought it was very informative. I appreciate you finding the time and
    energy to put this short article together. I once again find myself personally spending a lot of time both reading and posting comments.
    But so what, it was still worthwhile!

  10. hi! may i know is your code complete? because i run the program and does nothing, i have download the given source code.

    • Yes this code is working…You have to create file on php server to store FCM key into your database for future use. First check on your android studio log whether FCM token is printing OR not. If it is printing in log than send token to your web server.

  11. Good day! I could have sworn I’ve been to
    this website before but after going through
    a few of the articles I realized it’s new to me.

    Nonetheless, I’m certainly delighted I found it and I’ll be book-marking it and checking back regularly!

  12. Spot on with this write-up, I absolutely feel this website needs much more attention. I’ll probably be returning to read
    through more, thanks for the info!

  13. Hey very cool website!! Man .. Excellent ..
    Amazing .. I will bookmark your site and take the feeds additionally?
    I am glad to search out numerous useful info here
    in the submit, we need work out more strategies
    on this regard, thanks for sharing. . . . . .

  14. Pingback: ExoPlayer Android Example- Best Alternative of VideoView By Kamal

  15. Pingback: Simplest way to get WordPress Post in Android App- REST API

  16. I just like the helpful information you supply to your articles.

    I’ll bookmark your blog and test once more here frequently.
    I’m fairly sure I will learn many new stuff proper here!
    Good luck for the following!

Comments are closed.