Installation

To begin the adventure of programming for Android, we will need two things: the Java Developer Kit, and the Android SDK. JDK is simply Java with developer tools (eg Java compiler). The Android SDK includes a compiler for Android, a tool for creating and managing virtual devices (which we can test our programs), and the Eclipse development environment. Eclipse as such is a very popular IDE among Java developers, here we get its slightly modified for programming on the Android version. Nothing prevents us from using other environments, but using this crafted, ready version of Eclipse will be the simplest solution.

We choose the Java Platform (JDK), first from the left. The second one is different from the first additional tool – NetBeans, which we will not need here.

 

Click on the version selection screen. We choose a version of our operating system.

 

Next, download the Android SDK from:  http://developer.android.com/sdk/index.html

 

After downloading and unpacking, we should see the eclipse, sdk, and SDK Manager in the unpacked directory.

 

In the eclipse directory, there is an IDE to use, sdk is a tool like a compiler. The whole thing worth putting in a directory which we will not move anywhere later because we will in a moment add the subdirectories of the sdk directory to the PATH environment variable. Repositioning this directory would involve re-modifying the environment variable.

 

To set the environment variable in Windows, right-click on the “My Computer” icon and select “Properties”. Go to the “Advanced” tab and click the “Environment variables” button. Select the path variable from the system variables and click edit. To the variable we add paths to the tools, platform-tools and build-tools directory of the jdk directory, separating the paths with semicolons. We approve changes.

 

We run the Eclipse environment from the eclipse subdirectory. At startup, the program will ask us for the location of our workspace. Workspace is the space in which the source code we will create. Of course, it would be best if you could point out a catalog (we can create it by chance) which we will not move later.

 

When you first start, you should see this splash screen:

 

We close it. We should now see something like this:

 

When we start to create some more advanced programs, it may be that the default memory settings for Eclipse are insufficient and the environment will start to walk very slowly, hang on. So it’s time to make sure Eclipse has enough memory. To do this, edit the eclipse.ini file located in the Eclipse directory. We modify the memory parameters such as:

 

The new parameters will apply to the next Eclipse startup, so it’s a good idea to restart it. The effect of changes should be noticeable now, in the form of a difference in the startup time of the environment.

Configure virtual devices

To test our programs we can use real physical devices or use virtual ones. With such virtual machines, we will also be able to test our program with different device configurations and different screen sizes. To create such a virtual device, select “Android Virtual Device Manager” from the “window” menu in Elipse.

 

We will see a list of available virtual devices, temporarily empty.

 

Click the “New” button and enter the device configuration. You can model what I’ve introduced. This device is designed to simulate the SamsungAce3 model at least for the screen configuration. In fact, this phone has a lot more memory, but on the computer where it is configured 2GB of ram, and need to support other programs.

 

 

Once approved, you should see this view. We can create any number of devices and test the program on different screen sizes.

 

Directory structure in the application

Let’s look at the contents of the directories of our application.

The src directory contains the classes that we will create for the operation of our program, for example, the activity class.

The gene directory contains the elements that are generated by the compiler. The position of the elements is determined in the Xml files, the image type or sound resources will be uploaded as files. The compiled program will not include these elements in the form of files we throw in, and in the form of R.java file which is understandable for the runtime environment. In general, the contents of this directory should not be modified.

Bin directory contains compiled classes and our application as a finished application archive – apk. We do not move the contents of this catalog.

The libs directory contains the necessary library functions. We can throw in jary google maps if we use them.

Res directory (from resources) all static resources – pictures, sound files, video etc.

We also see a “free lying” AndroidManifest.xml file, which contains settings such as which activity (screen) is the main, the properties of the entire application as such (icon type etc), the permissions required by the program (eg to use the internet or GPS receiver).

 

 

Let’s look at the contents of the res directory. Anything you upload into this directory will become visible and accessible from anywhere in the application. This is where they should hit all the pictures, videos etc. The drawable-xxxxx directories are for images. There are several because we can have several versions of the same image for different resolutions. The names are quite intuitive – to the drawable-ldpi directory we put pictures for small resolution – low dot per inch. To drawable-hdpi, we put pictures for high resolution – high dot per inch. In the layout directory, we have XML files that specify the appearance of each activity. In the menu directory, we have files that define the appearance of menus on different screens.

In the values directory, we have a strings.xml file. Here we specify any captions that appear in the application. Of course, such subtitles can be set in java code, but if you put them in this file, it will be easier for us to manage captions once in one place. Storing subtitles in a separate XML file is of particular importance for the convenience of the later internationalization of the program.