Assignment No. 1 SD Module- Android Programming R (2) C (4) V (2) T (2) Total (10) Dated Sign Title: Download Install and Configure Android Studio on Linux /windows platform. Problem Definition: Install and Configure Android Studio on Linux. 1.1 Prerequisite: Basic concepts of Installation and Configuration of Android Studio on Linux. Concepts of Android Platform Architecture and component of Android. 1.2 Software Requirements: Android Studio 1.3 Tools/Framework/Language Used: Android Studio 1.4 Hardware Requirement: PIV, 4GB RAM, 500 GB HDD, Lenovo A13-4089 Model 1.5 Learning Objectives: Install and Configure Android Studio on Linux. 1.6 Outcomes: After completion of this assignment student are able to Understand How to Install and Configure Android Studio on Linux and Android Platform Architecture. 1.7 Theory Concepts: Android is a complete set of software for mobile devices such as tablet computers, notebooks, smartphones, electronic book readers, set-top boxes etc. It contains a linux-based Operating System, middleware and key mobile applications. It can be thought of as a mobile operating system. But it is not limited to mobile only. It is currently used in various devices such as mobiles, tablets, televisions etc. History of Android The history and versions of android are interesting to know. The code names of android ranges from A to J currently, such as Aestro, Blender, Cupcake, Donut, Eclair, Froyo,Gingerbread, Honeycomb, Ice Cream Sandwitch, Jelly Bean, KitKat and Lollipop. Let's understand the android history in a sequence. 1) Initially, Andy Rubin founded Android Incorporation in Palo Alto, California, United States in October, 2003. SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 1
2) In 17th August 2005, Google acquired android Incorporation. Since then, it is in the subsidiary of Google Incorporation. 3) The key employees of Android Incorporation are Andy Rubin, Rich Miner, Chris White andnick Sears. 4) Originally intended for camera but shifted to smart phones later because of low market for camera only. 5) Android is the nick name of Andy Rubin given by coworkers because of his love to robots. 6) In 2007, Google announces the development of android OS. 7) In 2008, HTC launched the first android mobile. Android Architecture android architecture or Android software stack is categorized into five parts: 1. linux kernel 2. native libraries (middleware), 3. Android Runtime 4. Application Framework 5. Applications Let's see the android architecture first. SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 2
1) Linux kernel It is the heart of android architecture that exists at the root of android architecture. Linux kernel is responsible for device drivers, power management, memory management, device management and resource access. 2) Native Libraries On the top of linux kernel, their are Native libraries such as WebKit, OpenGL, FreeType, SQLite, Media, C runtime library (libc) etc. The WebKit library is responsible for browser support, SQLite is for database, FreeType for font support, Media for playing and recording audio and video formats. 3) Android Runtime In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which is responsible to run android application. DVM is like JVM but it is optimized for mobile devices. It consumes less memory and provides fast performance. 4) Android Framework On the top of Native libraries and android runtime, there is android framework. Android framework includes Android API's such as UI (User Interface), telephony, resources, locations, Content Providers (data) and package managers. It provides a lot of classes and interfaces for android application development. 5) Applications On the top of android framework, there are applications. All applications such as home, contact, settings, games, browsers are using android framework that uses android runtime and libraries. Android runtime and native libraries are using linux kernal. An Android component is simply a piece of code that has a well defined life cycle e.g. Activity, Receiver, Service etc. The core building blocks or fundamental components of android are activities, views, intents, services, content providers, fragments and AndroidManifest.xml. Activity An activity is a class that represents a single screen. It is like a Frame in AWT. View A view is the UI element such as button, label, text field etc. Anything that you see is a view. Intent Intent is used to invoke components. It is mainly used to: o Start the service o Launch an activity o Display a web page o Display a list of contacts o Broadcast a message SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 3
o Dial a phone call etc. For example, you may write the following code to view the webpage. 1. Intent intent=new Intent(Intent.ACTION_VIEW); 2. intent.setdata(uri.parse("http://www.javatpoint.com")); 3. startactivity(intent); Service Service is a background process that can run for a long time. There are two types of services local and remote. Local service is accessed from within the application whereas remote service is accessed remotely from other applications running on the same device. Content Provider Content Providers are used to share data between the applications. Fragment Fragments are like parts of activity. An activity can display one or more fragments on the screen at the same time. AndroidManifest.xml It contains informations about activities, content providers, permissions etc. It is like the web.xml file in Java EE. Android Virtual Device (AVD) It is used to test the android application without the need for mobile or tablet etc. It can be created in different configurations to emulate different types of real devices. Android Emulator is used to run, debug and test the android application. If you don't have the real device, it can be the best way to run, debug and test the application. It uses an open source processor emulator technology called QEMU. The emulator tool enables you to start the emulator from the command line. You need to write: emulator -avd <AVD NAME> In case of Eclipse IDE, you can create AVD by Window menu > AVD Manager > New. In the given image, you can see the android emulator, it displays the output of the hello android example. Dalvik Virtual Machine DVM As we know the modern JVM is high performance and provides excellent memory management. But it needs to be optimized for low-powered handheld devices as well. The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile devices. It optimizes the virtual machine for memory, battery life and performance. Dalvik is a name of a town in Iceland. The Dalvik VM was written by Dan Bornstein. The Dex compiler converts the class files into the.dex file that run on the Dalvik VM. Multiple class files are converted into one dex file. Let's see the compiling and packaging process from the source file: SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 4
he javac tool compiles the java source file into the class file. The dx tool takes all the class files of your application and generates a single.dex file. It is a platformspecific tool. The Android Assets Packaging Tool (aapt) handles the packaging process. internal details or working of hello android example. SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 5
Android Studio is the premier tool produced by Google for creating Android apps and it more than matches that other IDE used by Microsoft developers for creating Windows phone apps. Step-1 Download And Install Android Studio The first tool you need to download is of course Android Studio. You can download Android Studio from the following website: https://developer.android.com/studio/index.html A green download button will appear and it will automatically detect that you are using Linux. A terms and conditions window will appear and you need to accept the agreement. The file will now start to download. When the file has completely downloaded open a terminal window. Now type the following command to get the name of the file that was downloaded: ls ~/Downloads A file should appear with a name which looks something like this: android-studio-ide-143.2915827-linux.zip Extract the zip file by running the following command: sudo unzip android-studio-ide-143.2915827-linux.zip -d /opt Replace the android filename with the one listed by the ls command. Step-2 SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 6
Download The Oracle JDK The Oracle Java Development Kit (JDK) may be available in your Linux distribution's package manager. If it is, install the JDK (must be 1.8 or above) using the package manager (i.e. Software Centre, Synaptic etc). If the JDK isn't available in the package manager to go to the following website: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html As of writing this article, there are downloads available for JDK version 8U91 and 8U92. I recommend choosing the 8U92 version. You will see links for Linux i586 and x64 in tar.gz format and RPM format. The x64 is for 64-bit machines. If you happen to be using a distribution that uses the RPM package formatdownload the RPM format. If you are using any other version download the tar.gz version. To install Java in RPM format run the following command: rpm -ivh jdk-8u92-linux-x64.rpm To install Java from the tar.gz file follow these instructions: cd /usr/local tar xvf ~/Downloads/jdk-8u92-linux-x64.tar.gz Now you need to make sure that this version of Java is the default. Run the following command: sudo update-alternatives --config java A list of Java versions will appear. SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 7
Enter the number for the option that has the words jdk in it. For example: /usr/java/jdk1.8.0_92/jre/bin/java /usr/local/jdk1.8.0_92/jre/bin/java Step-3 Run Android Studio To run Android Studio navigate to the /opt/android-studio/bin folder using the cd command: cd /opt/android-studio/bin Then run the following command: sh studio.sh A screen will appear asking whether you want to import settings. Choose the second option which reads as "I do not have a previous version of Studio or I do not want to import my settings". This will be followed by a Welcome screen. Click "Next" to continue Step-4 Choose An Installation Type Screen will appear with options for choosing standard settings or custom settings. Choose the standard settings option and click "Next". The next screen shows a list of components which will be downloaded. SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 8
The download size is quite large and is over 600 megabytes. Click "Next" to continue. now, click "Finish". Step-5 Creating Your First Project A screen will appear with options for creating a new project and opening existing projects. Choose the start a new project link. A screen will appear with the following fields: Application name Company domain Project location For this example change the application name to "HelloWorld" and leave the rest as the defaults. Click "Next" Step-6 Choose Which Android Devices To Target You can now choose which type of Android device you wish to target. The options are as follows: Phone/Tablet Wear TV Android Auto Glass For each option, you can choose the version of Android to target. If you choose "Phone and Tablet" and then look at the minimum SDK options you will see that for each option you choose it will show you how many devices will be able to run your app. I chose 4.1 Jellybean as it covers over 90% of the market but isn't too far behind. SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 9
Click "Next" Step-7 Choose An Activity A screen will appear asking for you to choose an activity. An activity in its simplest form is a screen and the one you choose here will act as your main activity. Choose "Basic Activity" and click "Next". You can now give the activity a name and a title. For this example leave them as they are and click "Finish". Step-8 How To Run Project SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 1 0
Android Studio will now load and you can run the default project that has been set up by pressing shift and F10. You will be asked to select a deployment target. The first time you run Android Studio there won't be a target. Click the "Create New Emulator" button. Step-9 Choose A Device To Emulate A list of devices will appear and you can choose one to use as a test device. Don't worry you don't need the actual device as the phone or tablet will be emulated by your computer. When you have chosen a device click "Next". SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 1 1
A screen will appear with recommended download options. Click the download link next to one of the options for a version of Android at the same SDK as your project target or higher. This causes a new download to occur. Click "Next". You will now be back at the choose a deployment target screen. Select the phone or tablet you downloaded and click OK. 1.8 Assignment Question? 1. Explain Android ActivityLifecycle? 2. Explain Android Fragment? 3. Explain Android Application Architecture? 4. What are the code names of android? 5. Explain Android Widget? 1.9 Oral Question? 1. What is current version of Android? 2. What is difference between Android and ios? 3. Who is founder of Android? 4. Does android support other language than java? 5. What is Activity? References:- https://www.lifewire.com/install-android-studio-for-linux-4056779 https://www.javatpoint.com/android-internal-storage-example Oral Question:- https://www.javatpoint.com/android-interview-questions SNJB S K.B.J. COLLEGE OF ENGINEERING, CHANDWAD 1 2