Setting Up The Android Studio IDE With The JDK And SDK

On the last post, i left some information about the basic tools used for Android Application Development and their download links. This time, i'm gonna show you how to set up the Android Studio IDE.

The first thing to do it's to make sure we have all the tools installed and working properly, so, the first thing to verify is that the Java Development Kit it's installed correctly.


Verifying the JDK

Open the Command Line (CMD on Windows, Terminal on Linux) and type: "java -version", this command should give us a response like this:


This response says that i have the JDK 8 Update 25, because it usually shows the most recent version installed, but i also have JDK 7u72 and 6u45 installed.

If you don't have a response like this one, you need to verify that you installed correctly the JDK, some times, we need to set the System Variable called "PATH" to point to the JDK folder.


Verifying the Android SDK

Once we check the JDK, it's time to check the Android SDK, for this, we just need to navigate to SDK folder, and launch the "<SDKFolder>/SDK Manager.exe" on windows, or "<SDKFolder>/tools/android" on linux. This will launch a new windows like this one:



As you can see, i have it all installed, but you don't need to install them all, just install the tools for the platforms you want to target, the extras you need and the platforms you will develop to, also make sure you install the Platform Tools, located under Tools folder, this will install the ADB, which it's the communication tool that allow us to deploy, install and debug our applications on Devices and/or Emulators.

If you will use an emulator, install also the corresponding system image for the android version you want to emulate.

NOTE: If your PC it's running on an Intel Processor, install the HAXM tool, located under the Extras folder at the bottom of the list, and make sure you download the System Image x86 to take advantage of this technology to acelerate the emulation, because the Android emulation it's slow as hell.


Setting The Android Studio IDE

After we check that the JDK and SDK are ready to work, we need to link these tools to the Android Studio, in order to make it able to compile our applications. To do so, we need to launch the Android Studio, which looks like this:



This is the main windows, which opens every time we launch the IDE, as long as we have no project's opened, in that case, will open the development window, which we'll see later.

By now, as we need to set the tools, we need to click on Configure, this will open up the next window:



Then click on Project Defaults:



Then, we click on Project Structure, where we'll find the 2 places to set the JDK and SDK:



On this windows, we are able to select our JDK and SDK locations, note that i'm using JDK 7 instead of JDK8, we can use the JDK8 but, we need to keep in mind that Most android versions uses JDK 6 and now JDK7 to compile the applications, we are limited to use the JDK features allowed by the android version.

In other words: from Android Donut (1) to Froyo (2.2), the system was developed with JDK 5, that means, that we need to keep using JDK5 features to be sure our applications runs on those devices.

From Gingerbread (2.3) to KitKat(4.4) the system was based on JDK6, so we're limited to the JDK6 features.

And now, for the new Android Lollipop (5), which is based on JDK7, we need to keep our apps using features from this JDK to be sure we're working the right way.

NOTE: We can use the JDK8 and develop apps for Lollipop, Kitkat , and more older android versions, but working based on one of the next patterns:

1 - Keep using older JDK features, which ensures our apps run on older android versions, but doesn't let us use the new enhancements made to the newer JDK's.

2 - Using multiple code sections, each one using features of an specific JDK, for example:

if(AndroidVersion == LolliPop)
{
    //Use JDK 7 Feaures
}
else if(AndroidVersion >= Gingerbread && AndroidVersion <= KitKat)
{
    //Use JDK6 Features
}
else
{
    //Use JDK5 Features
}

This allow us to target our app to a wide range of devices, and use specific features for each one, which it's great, but our code it's larger and more complex to Design, Develop and Maintain.

Once we set it all, click on OK to save the new configuration and start developing new Apps.

Well, that's all by now, see you on the next post, where we're gonna start creating a project.

Comments

Popular Posts