Eclipse_4.2_Juno_screenshot

Even if you don’t think we are fully in a Post-PC era, it is clear that mobile platforms play an essential role in many parts of our lives. Whether for fun or for profit, developing Android apps can be rewarding, both personally and financially. Assuming you have a certain level of technical knowledge then it is possible to develop Android apps yourself, but what programming languages do you need to learn? Actually, you have a number of options.

The official language for Android development is Java. Large parts of Android are written in Java and its APIs are designed to be called primarily from Java. That said, it is possible to develop C and C++ apps using the Android Native Development Kit (NDK), however it isn’t something that Google promotes. According to Google, “the NDK will not benefit most apps. As a developer, you need to balance its benefits against its drawbacks. Notably, using native code on Android generally does not result in a noticable performance improvement, but it always increases your app complexity.”

Java

The job of these virtual machines is to interpret the bytecode.

Java is a programming language first released by Sun Microsystems back in 1995. It can be found on many different types of devices from smartphones, to mainframe computers. You can use it on your desktop PC and even on the Raspberry Pi. Java doesn’t compile to native processor code but rather it relies on a “virtual machine” which understands an intermediate format called Java bytecode. Each platform that runs Java needs a virtual machine (VM)  implementation. On Android the original VM is called Dalvik. Google has also started previewing its next generation VM called ART. The job of these virtual machines is to interpret the bytecode, which is really just a set of instructions similar to the machine code found in CPUs, and execute the program on the processor. The VMs use a variety of technologies including  just-in-time compilation (JIT) and ahead-of-time compilation (AOT) to speed up the processes.

Must read: Java tutorial for beginners

What this all means is that you can develop Android apps on Windows, Linux or OS X and the Java compiler converts the source code into bytecode. This in turn is executed on the VM built-in to Android. This is different to the model used by iOS which uses a native compiler to turn Objective-C into ARM machine code.

Here is an example of what some Java looks like. This example uses a nested look to print out increasingly longer strings of asterisks:

for (int i = 0; i < 5; i++) {
  for (int j = 0; j <= i; j++) {
    System.out.print("*");
  }
  System.out.println();
}

This is a very simple example and the real code for an actual app is much more complex.

There are lots of online tutorials for learning Java including some here at Android Authority:

You might also want to look at the following tutorials:

Google offers Android Developer Tools (ADT) bundle which includes the SDK, a version of the Eclipse IDE with the ADT plugins, and the Android Platform-tools with the Android emulator.

Once you have learned Java, the next step is to learn how to use Java to create Android apps. For that you will need the Android Software Development Kit (SDK). The Android SDK provides all the API libraries and tools you need build an Android app. Google offers the Android Developer Tools (ADT) bundle which includes the SDK, a version of the Eclipse IDE with the ADT plugins, and the Android Platform-tools with the Android emulator.

Developing an Android app is more than just Java, you need to understand how the Android UI is constructed (using XML), and how to access the different Android subsystems. Google has a series of tutorials about Android development. The  Getting Started tutorial shows you the bare essentials of Android app development.

Corona

CoronaSDK-code-and-emulator

If you don’t want to learn Java or how to design user interfaces in XML, then there are alternatives. One is to use the Corona SDK. Corona is a high level SDK built on the LUA programming language. LUA is much simpler to learn than Java and the SDK takes away a lot of the pain in developing Android app. A simple app which displays a background image of your choice and writes some text on the screen can be written in just 3 lines of code with Corona.

Here is what some LUA code looks like, this does the same as the Java code above:

for i=1,5 do
  for j=1,i do
    io.write("*")
  end
  io.write("\n")
end

Here is the 3 line program to display a background image and write some text on the screen:

local background = display.newImage( "myimage.jpg", display.contentCenterX,
                                                     display.contentCenterY )
local myText = display.newText( "Hello, World!", display.contentCenterX,
                              display.contentWidth / 4, native.systemFont, 40 )
myText:setFillColor( 1, 110/255, 110/255 )

The first line loads the background image, the second line displays the text, and the third line sets the text color. Simple.

Almost everything in Corona is displayed via OpenGL.

Corona includes a sophisticated emulator which allows you to run your program instantly without needing to compile your code. When you want to create an Android .apk file you start a build via Corona’s online compilers and the app is saved to your PC.

Corona is designed mainly for games (but not exclusively) and as such includes libraries for sprites, audio, game networking and a 2D physics engine. Almost everything in Corona is displayed via OpenGL. This means you get GPU accelerated graphics, plus the default app is a blank canvas, all you need to do is start painting!

To find out more you should check out our writing your first Android game using the Corona SDK tutorial, plus Corona Labs provides a comprehensive set of getting started guides and tutorials including an Introduction to Lua and a Corona in 5 Minutes guide, which also includes an introduction to the 2D physics engine.

Corona is free to download and use, but if you want features like in-app purchasing or the ability to call native Android APIs you need to pay a monthly subscription fee.

Phonegap

Phonegap+JavascriptIf you already know HTML, CSS, and most importantly Javascript, then rather than learn Java or LUA, you can build Android apps using the skills you already have. Phonegap is based on Apache’s Cordova project. Basically it creates a webview which you can then populate and manipulate using Javascript. The web app can interact with the various device features, just like a native app, by referencing the cordova.js file to get the API bindings. Native functions which PhoneGap support include the accelerometer, the camera, the current location, the local storage and so on.

Here is how you would output the asterisks on a web page via Javascript:

var i, j;
for (i = 1; i <= 5; i += 1) {
  s = '';
  for (j = 0; j < i; j += 1)
    s += '*';
  document.write(s + '<BR>');
}

Other choices

Java, LUA and HTML/Javascript aren’t the only choices out there. In closing it is worth mentioning Titanium, another Javascript development system, and Gamesalad, a mobile game creator which allows you to create games without doing any coding! If you want to write Android apps in C# then you should check out Microsoft’s Visual Studio which now includes Xamarin’s C# SDK for mobile. Last, but not least, don’t forget the popular gaming engines Unity and Unreal.

Hot Java Android Coding Bundle

If you are serious about coding you should checkout our Android Coding bundle course with 60+ Hours of Training.
Get all 5 courses for just: $29  $657 [95% off]

Get this deal

If you have any experience using any of these development systems, or if you want to recommend a different one, please leave a comment below.

Next: Want to start making money from Android Apps? Here’s what NOT to do

See also: Android Studio for beginners 

Gary Sims
Gary has been a tech writer for over a decade and specializes in open source systems. He has a Bachelor's degree in Business Information Systems.He has many years of experience in system design and development as well as system administration, system security and networking protocols. He also knows several programming languages, as he was previously a software engineer for 10 years.
Show 54 comments