How to set up Android Studio for creating Android Apps And Games Using Linux

Datetime:2016-08-22 23:19:33          Topic: Android Studio           Share

Updated June 22, 2016 .

Introduction

In this guide I will show you how to install Android Studio using Linux.

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 .

Download Android Studio.

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.

Oracle JDK.

2.  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,Synapticetc).

If the JDK isn't available in the package manager 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 theRPM package formatdownload the RPM format.

If you are using any other version download thetar.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/localtar 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.

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

Run Android Studio Using Linux.

3.  Run Android Studio

To run Android Studio navigate to the /opt/android-studio/bin folder usingthe 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

Android Studio Installation Type.

4.  Choose An Installation Type

A 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. The download size is quite large and is over 600 megabytes.

Click "Next" to continue.

A screen may appear stating that you can run the Android emulator in KVM mode.

I will discuss this more later on but for now click "Finish".

More files will be downloaded.

Create Your First Android Project.

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"

Choose Which 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.

Click "Next"

Choose An Activity.

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".

Android Studio Running.

8.  How To Run Project

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.

Select Hardware.

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".

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.

Summary.

10.  Summary And Troubleshooting

You will now see a fully functioning phone boot up in an emulator and your application will load into the window.

You should now follow some tutorials for learning how to develop Android applications.

This video is a good starting point .

Whilst running the project you may get a message stating that you need a KVM emulator.

This is a 2 step process. In the first instance reboot your computer and enter your BIOS/UEFI settings and look for emulation. If the option is disabled change the value to enabled and save the changes.

Now within your Linux distribution within a terminal window try the following command:

sudo modprobe kvm_intel

or

sudo modprobe kvm_amd





About List