Association for Computing Machinery NIT Surat Student Chapter
ACM NIT Surat's Blog

Geek Quest

A platform to share interesting development ideas and examples.
Tutorials and interesting tech news would also be uploaded through this blog

Top Image

Getting started with Android Studio

Written by: Parthav

Development of an Android app can be done by many methods with its backend being written in Java, Kotlin, Dart or JavaScript. But for this post, we would only follow with Java and working with Android Studio which is based on the IntelliJ IDEA from JetBrains. To start with Android development we first need to set up our environment.

1. Install Android Studio:

Before installing Android Studio to your system please check if it meets the requirements to run Android Studio.
 
Requirements:
 

Windows

Mac

Linux

- Microsoft® Windows® 7/8/10 (32- or 64-bit)

- 3 GB RAM minimum, 8 GB RAM recommended; plus 1 GB for the Android Emulator

- 2 GB of available disk space minimum, 4 GB Recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)

- 1280 x 800 minimum screen resolution

- Mac® OS X® 10.10 (Yosemite) or higher, up to 10.13 (macOS High Sierra)

- 3 GB RAM minimum, 8 GB RAM recommended; plus 1 GB for the Android Emulator

- 2 GB of available disk space minimum, 4 GB Recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)

- 1280 x 800 minimum screen resolution

- GNOME or KDE desktop 
Tested on Ubuntu® 14.04 LTS, Trusty Tahr (64-bit distribution capable of running 32-bit applications)

- 64-bit distribution capable of running 32-bit applications

- GNU C Library (glibc) 2.19 or later

- 3 GB RAM minimum, 8 GB RAM recommended; plus 1 GB for the Android Emulator

- 2 GB of available disk space minimum, 4 GB Recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)

- 1280 x 800 minimum screen resolution

Installing Android Studio on any OS is really easy as mentioned in the steps over here.

2. Starting with Android Studio:

1. After starting the Android Studio and installing all the required SDK or plugins you can start a new project by clicking on "Start a new Android Studio project".

start new android studio project

 

2. In the Application Name field enter the name of the app you want and for the company domain use a unique domain address which will be used to name the java package. For now, keep it as "example.com".

naming project

 

3. On the next page select the target Android device version. Android applications usually have upward compatibility which means an app running in a lower version of Android would be compatible with the higher versions. But some features are only available for specific versions of Android in that case you need to think of which version to be selected as the target Android Version. For now, we can select Android 4.0.3 (IceCreamSandwich).

select SDK

 

4. For the next step, we need to select the type of activity for the main activity of your app. For now, we can select "Empty Activity".

activity selection

 

5. In the next step, we need to name the main activity of the app. For now, we can name it "MainActivity" and the XML file will automatically be named "activity_main".

finish project setup

 

Finally, press the finish button to finish setting up your Android app. As soon as you press finish the Android Studio starts indexing the project and building Gradle files. After the build, MainActivity.java and activity_main.xml files would be open on the IDE.

3. Running the App:

For running the app on an emulator or on a physical device (you need to enable USB debugging first) press the Run button in the toolbar and select the device on which you want to run the app.
The running app is a simple "Hello World!" (I know, cliche) displayed on the screen. Feel free to tinker with the XML file to change display screen.
Note: Once the app is built and run you can use the Apply Changes  button to quickly apply visual changes to the app.

Possible Errors or Downloads:

- Android Studio might want you to download the supporting Android SDK for your testing device or emulator.

- Android Studio might not recognize your physical device and not list it in the device list. Press the "Don't see your device?" and Android Studio would start a wizard to troubleshoot your problem.

Enable USB Debugging:

For ADB to recognize your device as a target for deploying debuggable APKs, you must first enable USB debugging in the on-device developer options.

Depending on the version of Android you're using, proceed as follows:

- On Android 8.0 and higher, go to Settings > System > About phone and tap Build number seven times.

- On Android 4.2 through 7.1.2, go to Settings > About phone and tap Build number seven times.

Return to the main Settings menu to find Developer options at the bottom. In the Developer options menu, scroll down and enable USB debugging.

 

Parthav| Comment