Write a program on android. Programming for Android: how to start creating your own applications and games

The article describes the main difficulties of creating applications for Android.
The basic concepts of Android programming are covered.
As an example, the creation of a Sudoku game from the book Hello, Android - Ed Burnette is described.
Be careful there are a lot of screenshots.

1. Development difficulties

Android is a unique operating system. The application developer must know its features and nuances to obtain a good result. There are some challenges that need to be taken into account when designing (). Let's list them briefly:
1) The application requires twice (or even four) more space for installation than the original size of the application.
2) The speed of working with files on the built-in flash drive drops tens of times as free space decreases.
3) Each process can use up to 16 MB (sometimes 24 MB) of RAM.

2. Principles for developing productive applications for Android

To work you need Android SDK and Eclipse. It is written about how to install everything and get started.

To load a project into Eclipse, follow these steps:
1) Unzip the project into a separate folder in the Eclipse workspace.
2) Select the menu item File->New->Android Project.
3) In the New Android Project dialog, select the Create project from existing source option.
4) In the Location field, specify the path to the folder with the project. Click Next.

Program menu

The game menu is described in the file res/layout/main.xml. The interface description can be edited as XML or as a rendered interface. To switch, use the tabs at the bottom of the content display area.

Typically controls are contained within a container, in our case a LinearLayout. It arranges all elements in one column.

Resources

Please note that all text labels (android:text) take data from resources. For example, the entry android:text="@string/main_title" specifies that the text should be looked for in the file res/values/string.xml in a node named main_title (Android Sudoku). The background color is also contained in the resources (android:background="@color/background") but in the color.xml file (#3500ffff). An error may occur when opening resource files in the editor. But you can always switch to XML display.

Controls that need to be accessed from code must have an id. Buttons have an id (android:id="@+id/continue_button") so that a click handler can be attached to the button. The plus sign indicates that you need to create an identifier for the button in the file /gen/org.example.sudoku/R.java (public static final int continue_button=0x7f0b000b;). This file is generated automatically and it is not recommended to modify it. The file contains the R class, through which you can access any interface element and other resources.

Creating Windows

Let's consider creating a window with information about the program. The layout of this window is in the /res/layout/about.xml file. The Activity class is described in the file /src/org.example.sudoku/About.java. The Activity is associated with markup in the AndroidManifest.xml file. This file can be viewed either through an editor or as XML. You can select different sections of the file in different editor tabs. The Application section contains Activity parameters. Note that the Theme parameter is :style/Theme.Dialog. This makes the window style more like a modal dialog.

The window with information about the program is called up from the Sudoku class by clicking the About button. The Sudoku class is written so that it handles the Click event itself (public class Sudoku extends Activity implements OnClickListener). The public void onClick(View v) method determines which button triggered the event and executes the corresponding code. To display the About window, the corresponding Intent is called.
case R.id.about_button:
Intent i = new Intent(this, About.class);
startActivity(i);
break;

Event handlers can also be installed on specific controls. For example, in the Keypad class, when the class is created, handlers for individual buttons are installed in the setListeners() method.

Simple dialogue

The user should be given the opportunity to choose the difficulty level. This is a small dialogue in which you need to choose one of several options. I’m very glad that you don’t need to create a separate Intent for this, but just use the AlertDialog class.
Let's look at the process of starting a new game. The user clicks on the New Game button. The click handler is a method of the Sudoku class - onClick. Next, the openNewGameDialog method is called, which shows the difficulty selection dialog and starts the game with the selected difficulty level. This dialog is built using the AlertDialog class.

Private void openNewGameDialog() ( new AlertDialog.Builder(this).setTitle(R.string.new_game_title).setItems(R.array.difficulty, new DialogInterface.OnClickListener() ( public void onClick(DialogInterface dialoginterface, int i) ( startGame (i); ) )).show();

Please note that the contents of the dialog (a set of buttons) are built from an array of strings R.array.difficulty. A dialog button click handler is immediately assigned, which, based on the number of the button pressed, starts a new game with a given difficulty level by calling the startGame method.

Graphic arts

The Game class is responsible for the game logic. Here tasks are loaded and winning conditions are checked. The Game class is an Activity, but the interface is not described in XML, but is created by code. The onCreate method creates a View:

PuzzleView = new PuzzleView(this);
setContentView(puzzleView);
puzzleView.requestFocus();

PazzleView is a class derived from View, it draws the playing field and processes screen touch events (onTouchEvent method) and key presses (onKeyDown method).

Let's look at the drawing process in Android. To draw, you need to overload the onDraw method. The method receives the Canvas object through which drawing is carried out. To set colors, objects of the Paint class are created. The color is specified in ARGB format. It is better to store color as resources (colors.xml file). Paint is not just a class for storing color information. For example, when drawing text, it contains information about the shading method, font, and alignment of the text.

Canvas contains a set of methods for drawing graphics (drawRect, drawLine, drawPath, drawText and others).

To optimize graphics, it is better to refrain from creating objects and unnecessary calculations inside the onDraw method (the considered example of graphics implementation is not optimal).

Music

The MediaPlayer class is used to play music. Music for the game has been added to the resources. You just need to copy the necessary files to the /res/raw folder (WAV, AAC, MP3, WMA, AMR, OGG, MIDI formats).
First you need to create an instance of the MediaPlayer class:
mp = MediaPlayer.create(context, resource);
here context is usually the class that initiates the launch of music, resource is the identifier of the resource with music. To control playback, use the start, stop and release methods.

In the game, music is played in the main menu (launched from the Sudoku class) and in gameplay (launched from the Game class). The Music class was created to control playback. The class contains a static instance of MediaPlayer, which eliminates the need to create a separate project for each launch of the audio resource.

In the Sudoku and Game classes, the onResume and onPause methods are overridden, in which music starts when the Activity starts and stops when deactivated.

conclusions

The example discussed in the article is not too complicated, which allows you to understand it without much effort. At the same time, it touches on various aspects of Android development.

P.S. Many thanks to the user

How to create a mobile application in Android Studio

Android Studio is an integrated development environment (IDE) based on IntelliJ IDEA, which Google calls the official IDE for Android applications.

This manual describes android application development:

  • Navigate between files using File Explorer
  • Installing the AndroidManifest.xml file
  • Importing files into a project
  • Advanced layout editor with dynamic preview feature
  • Using Logcat and Android Monitor to Debug Applications

Getting started in Android Studio

Launch Android Studio, in a window Android Studio Setup Wizard select Start a new Android Studio project(start a new project).

In the window Create New Project select Application Name(application name) as Fortune ball, enter the company domain; in field Project location select the location where the application will be saved. Click Next.

There is a window in front of you Target Android Devices. Select Phone and Tablet. In field Minimum SDK please indicate API 15. Click Next.

In the window Add an activity to Mobile select Basic Activity. Evaluate all the options, this window provides an overview of the available layouts.

Click Next.

In the window Customize the Activity, the screenshot of which is posted below, you can change Activity Name(name of activity), Layout Name(layout name), Title(common name) and Menu Resource Name(resource menu name). Leave the default values ​​and click Finish.

After a few seconds the following window will appear:

The same window will appear on your device or emulator. The emulator functions as a device and will take some time to load.

This is already an application. He lacks a lot, but now he can move on to the next step.

Project and file structure

The window shows the project files.

The drop-down menu (screenshot below) has several filters for files. The main ones are Project and Android.

The Project filter will show all application modules - each project contains at least one module. Other types of modules include modules from third-party libraries, or modules from other Android applications (such as Android Wear applications, Android TV). Each module has its own set of characteristics, including a gradle file, resources and source files (java files).

Note. If the project is not open, click the Project tab on the left side of the panel, as shown in the screenshot. By default, the Android filter is installed, which groups files by specific type. At the top level you will see the following folders:

  • manifests
  • Gradle Scripts

The following sections describe each of these folders in detail, starting with manifests.

Overview of AndroidManifest.xml

Every Android application has an AndroidManifest.xml file, which is located in the manifests folder. This XML file tells your system about the application's requirements. The presence of this file is mandatory, because it is what allows the Android system to create an application.

Open manifests folder and AndroidManifest.xml. Double click will open the file.

The manifest and application tags are needed for manifest and appear only once.

Each tag also defines a set of attributes, along with the element's name. For example, some attributes in application could be like this:

android:icon, android:label and android:theme

Among other things, the following may appear in manifest:

  • uses-permission: Requests a special permission that is given to the application in order to function correctly. For example, an application must ask the user for permission to access the network - in case you add the android.permission.INTERNET permission.
  • activity: Reports an activity that is partially responsible for the visual UI and logic. Any activity that is provided in the application must be added to the manifest - the system will not notice an unmarked activity, and it will not be displayed in the application.
  • service: Adds a service that you intend to use to implement long-running operations or advanced API communications with other applications. An example in this case would be a network call through which an application receives data. Unlike activities, services do not have user interfaces.
  • receiver: With a broadcast message receiver, an application receives signals about system messages or messages from other applications, even when other application components are not running. An example of such a situation is a battery with a low charge level and the operating system notifying about it.

A complete list of tags can be found in the manifest file on the Android Developer website.

Manifest file settings

Add the following attribute to activity:

android:screenOrientation=”portrait”. to limit the screen to portrait mode only. If this is not done, the screen, depending on the location of the device, will be in either landscape or portrait mode. After adding the attribute, the manifest file will look like the screenshot.

Create and run the application. If you are testing on your device, flip it over, make sure the screen does not move to landscape mode if you have limited this ability in the AndroidManifest file.

Gradle overview

Let's move on to Gradle. Gradle turns an Android project into an installable APK that can be installed on devices. The build.gradle file is present in Gradle scripts, at two levels: module and project.

Open the build.gradle file (Module:app). You will see the default gradle installation:

apply plugin: "com.android.application" android (compileSdkVersion 25buildToolsVersion "25.0.2" defaultConfig (applicationId "com.raywenderlich.fortuneball" minSdkVersion 15targetSdkVersion 25versionCode 1versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitR unner")buildTypes (release (minifyEnabled falseproguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"))) dependencies (compile fileTree(dir: "libs", include: ["*.jar"])androidTestCompile(" com.android.support.test.espresso:espresso-core:2.2.2", (exclude group: "com.android.support", module: "support-annotations"))compile "com.android.support:appcompat- v7:25.1.0"compile "com.android.support:design:25.1.0"testCompile "junit:junit:4.12")

Let's look at the main components:

  • apply plugin: 'com.android.application' applies the Android plugin at the parent level and makes available the top-level tasks needed to build the application.
  • Next to the android(…) section are settings options such as targetSdkVersion. The target SDK for your application should be at the latest API level. Another important component is minSDKVersion (defines the minimum SDK version that must be installed on the device for the application to run). For example, if the SDK version is 14, then the application will not be able to run on that device, since in this particular case the minimum supported version is 15.
  • The last component is dependencies(…). It is necessary to note compile 'com.android.support:appcompat-v7:VERSION' and compile 'com.android.support:design:VERSION'. They provide support and compatibility of features of new and old APIs.

In addition to Android compatibility libraries, you can add third-party libraries to the dependencies(...) component. The animation library, for example, contains UI effects. Find dependencies, then add the following two lines down:

dependencies ( ... compile "com.daimajia.easing:library:2.0@aar" compile "com.daimajia.androidanimations:library:2.2@aar")

Here you can add third-party dependencies. Libraries are automatically downloaded and integrated into Android Studio. Click Sync Now to integrate these dependencies into your application.

Synchronization takes a few seconds. Gradle updates appear in the Messages tab of the bottom panel.

These are all the settings you will need in Gradle for now. Such manipulations will add animation to the application.

Importing files

When developing an Android application, integration with other resources is important: images, custom fonts, sounds, videos, etc. These resources are imported into Android Studio and placed in the appropriate folders, which allows the operating system to select the correct resources for the application. Our Fortune Ball application will need to import images into the drawable folders. These folders can contain images or special XML drawables files (i.e. you can draw shapes using XML code and use them in your layouts).

In Android Studio, go from Android to Project

Open the res folder (app > src > main). Right-click on the res folder, select New > Android resource directory.

A window called New Resource Directory will appear.

From the Resource type drop-down list, select the drawable option. In the Available qualifiers list, select Density, then click the button that is highlighted in the screenshot.

In the next window, select XX-High Density from the Density list. Click OK.

Repeat everything to create drawable-xhdpi, drawable-hdpi and drawable-mdpi folders. Select X-High, high and medium density respectively from the Density list.

Each folder that has a density identifier (i.e. xxhdpi, xhdpi, hdpi) contains images that are associated with a specific density or resolution. For example, the drawable-xxhdpi folder contains a high-density image, which means that an Android device with a high-resolution screen will draw the image from this folder. The image will look good on all Android devices, regardless of screen quality. More information about screen densities can be found in the Android documentation.

Once you've created all the "drawn" folders, you can go back to the unzipped content in the folder and copy (cmd + C) the image from each folder and place (cmd + V) in the corresponding Android Studio folder.

Once you have placed the files, you will see the Copy window. Select OK.

XML View and Dynamic Layout Previews

Creating a layout that users can interact with is an important part of the process. In Android Studio, this can be done in the layout editor. Open content_main.xml from res/layout. In the Design tab you can move interface elements (buttons, text fields).

To the right of Design there is a Text tab that allows you to edit XML directly in the layout.

Before creating the appearance, you need to define some values. Open strings.xml in the res/values ​​tab and add the following:

Suggest the question, which you can answer “yes” or “no”, then click on the magic ball.

strings.xml contains all the strings that appear in the application. Separating these lines into separate files makes internationalization easier because You only need a string file for each language that is required in the application. Even if you don't intend to translate your application into other languages, using a string file is always recommended.

Open dimens.xml in res/values ​​and add the following:

15sp20sp

dimens.xml contains dimensional values, limit intervals for layouts, text size, etc. It is recommended to save this data in a file so that it can be used to create layouts in the future.

Go back to content_main.xml and replace the entire contents of the file with the following code:

This rather large code creates a layout for an application called FortuneBall. At the top level you have added a RelativeLayout (relative layout defines the position of the child components relative to the parent component). RelativeLayout can be stretched to fit the size of the parent component.

Relative markup adds two pieces of text, an image and a button. All these details will be visible in the order they were added. Their contents can be read in strings.xml (text) and drawable (images).

While updating content_main.xml, notice that the Preview window updates the UI:

Note: if the preview window is not visible, in the Text tab, click on the Preview button in the markup editor panel on the right.

Create and launch.

And now you have created the application layout. But at this stage it's just a pretty image - clicking on the button won't lead to anything.

Combining Activity and View

You can use java files located in app/src/main/java to establish logical connections in the application.

Open MainActivity.java and add this data under the existing ones:

Import java.util.Random;import android.view.View;import android.widget.Button;import android.widget.ImageView;import android.widget.TextView; import com.daimajia.androidanimations.library.Techniques;import com.daimajia.androidanimations.library.YoYo;

The first five imports point to the corresponding classes in your code: Random, View, Button, ImageView, and TextView. The following two imports indicate that you will use two classes from libraries, incl. build.gradle for animations. In MainActivity.java, in the MainActivity class, add:

String fortuneList = ("Don't count on it","Ask again later","You may rely on it","Without a doubt","Outlook not so good","It"s decidedly so","Signs point to yes","Yes definitely","Yes","My sources say NO"); TextView mFortuneText;Button mGenerateFortuneButton;ImageView mFortuneBallImage;

In this short piece of code you have set 4 variables for the activity. The first is the lines that define the possible states, the other three are the UI elements you created in the layout/markup.

Now replace the contents of the onCreate() method with the following:

// 1:super.onCreate(savedInstanceState);// 2:setContentView(R.layout.activity_main);Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);setSupportActionBar(toolbar);// 3:mFortuneText = (TextView) findViewById(R.id.fortuneText);mFortuneBallImage = (ImageView) findViewById(R.id.fortunateImage);mGenerateFortuneButton = ( Button) findViewById(R.id.fortuneButton); // 4:mGenerateFortuneButton.setOnClickListener(new View.OnClickListener() (@Overridepublic void onClick( View view) (// 5:int index = new Random().nextInt(fortuneList.length);mFortuneText.setText(fortuneList);// 6:YoYo.with(Techniques.Swing).duration(500).playOn(mFortuneBallImage);)));

  • Check that the activity is ready (superclass implementation).
  • Specify that the layout for this activity is represented by the layout you created earlier, check the toolbar.
  • Fill in the values ​​of the three variables you created earlier in the layout's views components using the findViewById method. The id value is the same as in the XML layout.
  • Add an OnClickListener on the button. This is a simple class that encapsulates (packages) the functionality that a button click calls.
  • Select a random option from the fortuneList set for this application, and update the fortune text to show it.
  • Use a third party library to add the dependency to the gradle file and thus add animation to the application.

It's almost ready. But you need to remove the floating button. Go to res/layout and open activity_main.xml.

This layout file contains a link to the content_main.xml that you previously edited. It defines the content by default (toolbar and floating action button). However, in this particular application (Fortune Ball), a floating button is not needed. Therefore, remove the following block of code from the xml file:

There is no longer a floating button in the lower right corner.

Ask a question (What’s my fortune?) - press the button. Check the application.

Android Monitor

Android Studio contains a wide variety of tools. Open the Android Monitor tab at the bottom of the Android Studio window.

Here you will find many options for the developer.

  • The camera and play button on the left allow you to take screenshots and record videos.
  • The magnifying glass opens up a number of additional options, such as analyzing the application's memory.
  • The Layout Inspector provides a visual interface that determines why an application's interface looks a certain way.

LogCat provides a detailed overview of system messages with the ability to drill down into specific application data, or even use the search bar to filter messages if they don't contain specific characters.

Make sure you have selected Show only selected application in the top right corner as shown in the screenshot above. Now only your app's messages will be visible.

In MainActivity.java, add the following to the list of imports:

Import android.util.Log;

At the end of onCreate() in MainActivity.java add the following line:

Log.v("FORTUNE APP TAG","onCreateCalled");

Log.v calls two parameters - tag and message. In this case, the tag is defined as “FORTUNE APP TAG” and the message is defined as “onCreateCalled”.

Run the application to see the log message in the Logcat panel.

Filter the contents of LogCat, enter onCreateCalled in the search bar above the console:

Then delete the search text to see all log messages again.

Another useful feature is logcat, which is the ability to view error messages. Add a bug to your perfectly functional application to see how things work.

Go to MainActivity.java and change the following line in onCreate():

//mFortuneText = (TextView) findViewById(R.id.fortuneText);

Launch the application. Click the What's My Fortune? button Does not work!

How would you fix the error if you didn't know there was a bug? Logcat will help with this.

Go to the Logcat panel - it looks something like this:

There's a lot of red text here. In this case, the problem is line 50 in the MainActivity.java file. LogCat turned this link into a blue hyperlink. If you press it, you can find out what the problem is.

By changing mFortuneText = (TextView) findViewById(R.id.fortuneText), you created a variable but did not specify its value - hence the null pointer exception. Go back and change the code, run the application. This time everything works smoothly. Logcat is a useful tool for finding errors.

Share this article:

Related Articles

Do you doubt whether it is worth investing in mobile application development? You can do it yourself and absolutely free. You may end up with a test version that can be used to conveniently evaluate the effectiveness of your mobile strategy. And if you try, you will make a decent mobile application that will become the main tool for online interaction with owners of smartphones and tablets.

Is it worth making your own mobile app?

Costs. If you don't take my word for it, here are some facts:

  • According to Flurry Analytics and comScore, owners of smartphones and tablets use the browser only 14% of the total time they work with the device. And they spend 86% of their time on different applications.
  • The installed application is your direct channel of communication with the consumer. Just think: you don’t need to spend money on advertising or wait for a person to find you using Yandex. All that remains is to support the functionality the user needs and provide him with relevant content.
  • The number of purchases made using tablets and smartphones is growing both on the Internet in general and on the RuNet. According to marketing agency Criteo, already in 2016, more than half of online transactions in RuNet will be made using mobile devices.

If you want, the application is a mobile browser in which only your website opens. In what case would a user install such an Internet browser? Only if he is interested in your product or information. Therefore, remember: the client who installed the application is a loyal and ready-to-buy representative of the target audience.

In this case, is it worth taking the risk and offering DIY applications to loyal customers rather than custom programs made by professionals for Android and iOS? Let's figure it out.

When can you create an application yourself?

Do you remember what website visitors need? They come because of the content or functionality of the resource. People want to get information, buy something, look at and comment on friends' photos, and so on. Mobile app users need the same. They are looking for information or making some kind of transaction.

Do you remember when a business could make a website on its own? It’s right when you don’t yet have money to collaborate with professionals, but you still have the time and desire to figure out WordPress or Joomla. The same situation is with applications. Self-created programs for iOS and Android can be roughly compared to websites built on open source engines.

You don't have to register to start working. Click the Create Now button on the main page or select the Create App menu in the upper right corner on any page of the service.


Select the appropriate application template. If we are talking about a content project, you may be interested in the following options:

  • Manual. This template allows you to create a guide program.
  • Blog. The application will help your blog audience read new notes from the screen of a smartphone or tablet.
  • Website. The template converts a website into an application.
  • Pages. With this template you can convert any content into an application with simple functionality.
  • News. The template allows you to create an application that is an aggregator of industry or regional news.
  • Page. The template converts offline content, such as an e-book, into the application.
  • VK Page and Facebook Page. Create an application that allows you to monitor updates of open groups on VKontakte and Facebook.
  • YouTube. Use the template to promote your YouTube channel.

How to Create a Blog App

Use the Blog template. In the appropriate field, enter the URL of your blog or RSS feed. Select a note title color.


Enter the name of the application.


Add a description.


Choose a standard one or add a custom icon. The appropriate image size is 512 by 512 pixels.


To create a download file, click the Create App button. After this, you need to register in the system. Confirm your registration and go to your personal account. Here you can install the application on your mobile device, publish it on Google Play and Amazon App Store. The system also offers a monetization option. If you use this feature, advertisements will be displayed in the application.


Check how the application works on your mobile device. On a tablet, the program should display a list of blog posts in title and announcement format.

In your AppsGeyser personal account, you can monitor the number of installations, create push notifications, publish the application in stores, monetize the program using advertising, and edit the application.

Use the editor to add text, images, videos or links. To add a photo to the program, upload it to Imgur hosting and paste the link into the appropriate field.


After editing the content, specify the name of the application, add a description and an icon. Click the Create App button. After creating the download file, install it on your mobile device and check its functionality.

Please note that most mobile devices block the installation of applications from unknown sources by default. If a user downloads a program from your site or an app builder site, they will see a security warning when they try to install it. Some clients will probably refuse to install the program.


8 constructors similar to AppsGeyser

If the universal AppsGeyser constructor is not suitable for you, pay attention to similar services:

  • AppsMakerStore. Using the service, you can create applications of various types: from programs for Ecommerce to solutions for content projects. The designer makes applications for iOS and Android. The service interface is Russified. For beginners, there is an informative guide to using the constructor. The service is paid.
  • . Free Android app builder. You can publish the created programs on Google Play and monetize with advertising.
  • Appery. Paid constructor for creating universal applications. You can evaluate its functionality by taking advantage of a free trial period of access.
  • Good Barber. Using this service you can develop Android and iOS applications. The constructor is paid, the cost of use is 16 USD per month.

Most of the services offered have an English-language interface. If you are uncomfortable working with constructors in English, choose platforms with Russian-language content.

Application designers: a stone ax or a thin modern tool?

Don't go from one extreme to another. With the help of the proposed services, you can really create functional functional applications. The resulting programs can be used to solve various problems: from facilitating online trading to distributing content and educating the audience. Applications created in the designer can be published on Google Play and the App Store, edited, and monetized using advertising or paid installations.

Remember that simply creating an application is not enough. It is necessary to invest a lot of effort in its promotion. Contact us if you want to entrust this work to professionals who know exactly what needs to be done to attract new users.

Do not overestimate the services offered. Their obvious drawback remains their stereotyped nature. We are talking about both the design and functionality of the programs. In addition, access to platforms with decent functionality is paid. What is better: to pay the developers for their work once or to pay the owners of the designer for many years? Do the math for yourself.

And one more thing: if you don’t have time to create a mobile application yourself, contact our company. We develop mobile applications and .

Contact us Shall we discuss? Order a free consultation

Every year, the Android operating system becomes not only a suitable OS for ordinary users, but also a powerful platform for developers. Well, what can you do: Google always meets developers halfway, providing ample opportunities and powerful tools, seasoned with informative documentation.
In addition, one should not lose sight of the fact that the “green robot” is the leader in popularity among mobile operating systems. This suggests that by programming for Android, you will have a wide audience, which can later bring profit. In general, Android is a kind of “oasis” for developers. Therefore, we have prepared for you a special selection of programming languages, as well as development environments for this OS.
Attention, a little advice for beginners
: Android programming may seem difficult or too monotonous at first. Tip: Check out the links to useful documentation before you get started, and then programming on Android will not be a problem for you.

Java is the main tool for Android developers

Development environments: Android Studio (IntelliJ IDEA), Eclipse + ADT plugin
Suitable for wide range of tasks
Java is the main language for Android programmers, a must-have for beginners. The main Android source code is written in this language, so it's easy to see why most people choose this language. Applications written in Java run on Android using the ART virtual machine (or Dalvik in Jelly Bean and earlier versions of Android), an analogue of the Java virtual machine, over which Google has a serious legal battle with Oracle.

Google currently officially supports the fairly powerful Android Studio development environment, which is built on Intellij IDEA from JetBrains. Also, don’t forget about the very detailed documentation from Google, which covers everything from match_parent and wrap_content to constructors, constants and main methods of the JavaHttpConnection class - it’s definitely worth reading.

Also, don't forget about Eclipse, a very popular environment for Java programmers. With the official ADT plugin from Google, this toolkit will become a powerful and lightweight weapon in your hands. But the guys from Mountain View stopped supporting Eclipse since last summer, giving way to the new Android Studio. Recommended for use on weak PCs.

Required documentation:

C++ is a powerful tool in the hands of a master

Main development environments: Android Studio (version 1.3 and higher), Visual Studio 2015, QtCreator
Suitable for game engines and resource-intensive applications.
C++ is a middle-aged but very powerful programming language that celebrated its thirtieth anniversary last year. It was invented in 1985 thanks to the efforts of friend Björn Stroustrup and still occupies the top positions of the most popular programming languages. “Pros” give you complete freedom of action, limiting you only to what is reasonable.


Over the entire existence of Android, many frameworks and development tools for C++ have been created. I would especially like to highlight the well-known Qt and IDE QtCreator, which allow you to develop cross-platform applications for Windows, Windows Phone, Windows RT, iOS, SailfishOS and Android (once this list also included Symbian). In addition, you get a convenient Tulip library of containers, algorithms and templates, which absorbs the best of Java and Android. And finally, you get many different QT modules for high- and low-level work with the system. Your humble servant codes specifically in C++ and Qt.

Last year, at the Windows: The Next Champter conference, widespread attention was paid to the fairly popular development environment Visual Studio 2015. One of the main innovations was support for developing applications for both Windows Phone and Android - Microsoft tried to somehow increase the number of applications for your OS.

It is also impossible not to mention that the official Android Studio began to support NDK. With the help of the NDK, you can use OpenGL graphics when working with Android. If you need speed and efficiency - choose NDK! This development method is perfect for game engines that require high performance.

Android development in C or C++ may seem simpler than in Java, but despite the fact that the language offers you complete freedom of action and does not limit you in your steps, it has some specific features that will take a lot of time to learn - not without reason C++ has been compared to nunchucks (an excellent weapon that unfortunately requires great skill). However, developing Android applications in C and C++ can be fun.

Required documentation:

Other languages

Now is the time to talk about other less popular, but also interesting languages ​​and frameworks for them. However, for many reasons, you won't be as successful as you are with Java and C++.

Corona (LUA Script)


Suitable for creating games and simple applications
If for some reason you don’t want to learn Java or understand building an interface via XML, then you can choose this IDE for yourself. Corona is a fairly lightweight development environment, the code in which must be written in a fairly lightweight LUA (Pascal lovers will appreciate it).

This toolkit will help you write simple 2D games, for which there are libraries for 2D objects, sounds, network and game engine. The games created work with OpenGL, which means high efficiency. Great for beginners, perhaps this is where you can create your first mobile application on Android!


Required documentation:

Adobe PhoneGap (HTML5, JavaScript, CSS)


Suitable for creating non-resource-intensive applications
If you are already familiar with HTML, CSS and JavaScript, you can try PhoneGap as an alternative. This IDE will allow you to build full-fledged applications developed in the above-mentioned programming and markup languages.

In fact, ready-made applications from PhoneGap are the simplest WebViews, animated using JavaScript. Using various APIs, you can use various device functionality just like in native applications. What's interesting is that the applications are compiled on the server and then available for use on iOS, Android, Windows Phone, Web OS and BlackBerry OS. With such broad cross-platform functionality, app development can speed up significantly.


Required documentation:

Fuse (JavaScript and UX)


Suitable for creating both simple and complex applications
When people talk about Android development tools, they often think of Fuse. This tool is one of the most user-friendly of its kind, and it can present a wide range of possibilities and benefits to the developer.

The main logic of Fuse applications is built on JavaScript - a simple and understandable language with a low entry threshold. The interface foundation is represented by UX markup - intuitively understandable to everyone. Well, the “buns” of the environment will allow you to apply changes directly while the application is running on your device or emulator - just like in Android Studio 2.0 and higher. With Fuse, Android app development can be easy and enjoyable.

Required documentation:

The words "at the end"

Of course, we have not shown you all the currently existing development tools. With this article we wanted to explain to you that becoming an Android developer is not so difficult, although it often requires effort and perseverance. The world of development for mobile platforms is open to you, but remember: the first step is always yours.

The Android operating system is installed on 66.71% of all mobile devices in the world. So it is not surprising that many beginning IT specialists want to realize their ambitions on this platform.

Most recently on GeekBrains we touched on mobile platforms, but this time we’ll take a closer look at Android. Here are 10 languages ​​that will allow you to create a mobile application of any type and complexity:

Java

It wouldn't be much of an exaggeration to call Java the official language of Android. In any case, almost all educational documentation, all online courses are based on this. It is also the most popular language according to TIOBE, the second in the number of sources on GitHub, and in general a big beautiful language. This is why learning Java should be a top priority for any Android developer. Even though it won’t be easy (after all, the language is 22 years old, and ease has never been its strong point), even though theoretically you can get by with more modern languages, remember - it is impossible to achieve significant success on Android without absolutely understanding Java, not to mention specific source codes.

C#

With all the endless skepticism directed towards Microsoft products, it is worth admitting that C# does not deserve it. This is a wonderful language that has absorbed all the best from Java, while taking into account and correcting many of the shortcomings.

When it comes to Android application development, you have one of the most functional environments at your disposal: Visual and Xamarin Studio. And knowing C# will be a nice bonus for you when you get to using Unity 3D. With this set the possibilities are endless.

Python

Just because Android doesn't support using Python to build native apps doesn't mean it's not possible. Fans of this snake language have developed many tools that allow you to compile Python code into the required state.

The most popular framework is Kivy, which can easily help you create an application for the Play Market in pure Python. And if not, then kind developers will help in the chat. If you haven't mastered it yet, we recommend taking it.

Kotlin

In the text about, I already tried to explain why Kotlin itself is an excellent language, and in conjunction with Java it is even better. Indeed, officially released only a year ago, Kotlin is quickly winning the hearts of developers around the world with its almost complete absence of flaws.

With its help (more precisely, with the help of the native IntelliJ IDEA environment), you will not feel any problems in developing native applications for Android. At the same time, the demand for Kotlin specialists is still low, which means that by gaining experience working with it, you risk gaining a competitive advantage in the future.

Web languages

Standard web worker language set: HTML, CSS and JavaScript. Without knowing these 3 languages, you will reduce yourself to developing applications with a rather narrow focus. Even if you don’t want to touch the web directly in your future work, it’s unlikely that you can avoid hybrid applications.

You can work with HTML, CSS and JavaScript using the PhoneGap Build environment or, in a more specialized case, Adobe Cordova. They will not require much knowledge from you, but will provide results. Or from the last one, React Native from Facebook is the next level of ease of interaction, but little experience and documentation has accumulated. In general, choose, fortunately there is plenty to choose from.

Lua

A language that is older than Java, much less popular, but still in demand. It has a number of advantages, such as dynamic typing and relatively simple syntax, but it has survived to this day thanks to its involvement in games. It was the convenience of creating a software layer between the engine and the shell that opened the door for Lua to the world of pocket gadgets.

Corona SDK is an environment for developing mobile cross-platform applications, mainly games, where the main tool is Lua. Since 2015, it has been distributed free of charge, designed for beginner developers, plus you can find a lot of useful information in both the English and Russian segments of the Internet.

C/C++

Google actually provides developers with two development environments: the SDK, which is designed to work with Java, and the NDK, where the native languages ​​are C/C++. Yes, of course, you won’t write an entire application using only these languages, but with their help you can create a library, which you can later connect to the main body of the program using Java.

Even though the vast majority of developers don't care about the NDK, by using this tool you will get better results in terms of performance and internal resource utilization. And this is exactly what on Android distinguishes a good app idea from a good implementation.

What languages ​​do you write in?