Android Development: So, You Want to Be an App Developer?

Android app development

So, you want to be an app developer? Let’s see what I can do to help you with that! A casual survey of the back issues of ODROID Magazine has shown that there are plenty of in-depth, detailed articles about Android on ODROID. What the community has been missing is a series of “So, you want to get started with this” articles for Android app development. Sure, there are plenty of YouTube videos with questionable audio and video quality, as well as blogs and tutorials online that you may or may not be able to find through a search, but rather than muddle through all that noise, I thought it would be helpful to throw my proverbial hat into the “Getting Started” ring.

Aside from being capable single-board Linux computers, ODROID models such as the C1+, C2, and even the XU4 are well-suited for Android app development, whether for handheld, tablet, or automotive use. I own a well-loved ODROID-C1 that I purchased a couple years ago and while it may be a bit older than the latest generation of available hardware, the brain inside is the same as the current ODROID-C0 and C1+ and is still a valid, affordable test platform for trying out Android apps.

Walk before you run

Before we dive into using ODROID boards for app development, we need to cover a few basics. First, you will need to have a way to create the software that you will run on the Android OS. In order to do that, you’ll need a development environment, which is a collection of tools that work together to create the application. Android has a few options for developing programs in an Integrated Development Environment (IDE). We will focus on the “official” one, Android Studio.

Second, you will need to have a safe place to store your work. While personally I’m a fan of the self-hosting, I recognize that any good backup strategy involves storing a copy of your data offsite. So make sure to sign up for an online git-based source code repository on a hosted git provider such as Github, Gitlab, or Bitbucket.

Finally, let’s take a moment to outline what a sane software development process should look like, both in general and specifically for Android:

  • Setting up the development environment
  • Set up Android on ODROID
  • Create the Hello World app
  • Deploy app to Android/ODROID
  • Iterate!

Setting up the development environment

When you set up a development environment, you will most likely do it on one of three operating systems: Linux, Windows or macOS. For this column, I will install Android Studio on my Mac but you will find the process substantially similar, regardless of platform. Begin by visiting the Android Studio download page at https://developer.android.com/studio. The page will generally select the correct download for your operating system (OS), but you can always download any of the installers or bundles for whatever OS you wish.

As of this writing, the Android Studio installation instructions are very straightforward and include specific steps for each supported OS, which are available at https://developer.android.com/studio/install.html. The installation on my Mac was detailed and remarkably painless. The installer downloads a variety of Android libraries needed for development and provides the Intel HAXM hypervisor to assist in Android emulation down the road. In just a few minutes, the job is done, as shown in Figure 1.

Figure 1 – Downloading components

Once you click “Finish”, the app will start and you’ll be confronted by a list of choices. For now, select “Start a new Android Studio project” and have a look around. Of course, you’ll be immediately plunged into the world of Java programming on the “Create Android Project” screen as you’ll be asked to come up with a “company domain.”, which I’ll explain in the next section.

What domain?

In Java, all object classes are divided into namespaces, which are basically groupings where you can safely create Java classes, which can be named in whatever way you want, that won’t clobber someone else’s Java class definitions. It’s similar in concept to domain names on the web, which is why Android Studio refers to it as a “company domain”, as illustrated in Figure 2. For now, you can put any domain you want, but definitely don’t use a domain that you don’t own or control.

Figure 2 – Create Android project

You can see the resulting namespace for this new project by looking at the “Package Name” field on that screen, which in my case shows “com.randy_hall.myfirstapp”. For now, understand that this is how Java and, by extension, Android, works.

What Device?

Next, we’ll look at what level of Android API we want to use for this project. This is both an incredible advantage of Android, and one of its most frustrating shortcomings. There is such a wide variety of software versions of Android out in the world that when you choose to support one API level over another, you inherently exclude a number of Android devices from using your app. For now, let’s be reasonable and choose “API 21: Android 5.0 (Lollipop)” as shown in Figure 3, which, according to Android Studio, will mean that our app will run on about 71.3% of Android devices as of this writing. As new Android devices are introduced and old phones get upgraded or decommissioned, this number will generally increase over time.

Figure 3 – Target Android devices

Adding activity

Android Studio can help get you off the ground a bit more quickly by providing some scaffolding, which are templates of common application patterns that provide a starting point to begin your work. There are several to choose from, which we will talk more about in the future, but for now let’s pick “Empty Activity”, as shown in Figure 4.

Figure 4 – Add an activity to mobile

You will be asked to configure the empty activity by giving it a name and a layout name. Both of these will be used to generate code for the project, so you can name it however you like. I will stick with the defaults of “MainActivity” and “activity_main”, but you can always change them later in the code.

Once the MainActivity has been generated, things start moving forward! We have clicked a lot, and Android Studio has done some background work, but now we are in the IDE, ready to get started. You may notice right away that the amount of code generated is relatively small. That’s in large part because we chose an Empty Activity, which is remarkably empty! If we had chosen another activity to generate, we would have been faced with considerably larger amount of code to look through.

Along the way, I got a “Gradle Sync” error, as shown in Figure 5, which means that I don’t have the most recent Android API installed. I clicked the “Install missing platform(s)” and hit refresh, after which the error repeated itself for the build tools. Installing both of these pieces (if they weren’t already there) got me past that hurdle and on to the workspace, ready for coding.

Figure 5 – Gradle Sync error

Git with it

Now we are ready to move to the next step, which is creating a hosted git account to store and perhaps share our work. For this, we will use one of the slightly less well-known hosted git providers, Github (https://www.github.com).

Hosted git providers like Github, Gitlab, and Bitbucket are all based on the widely used open-source git version control software. We can get into the philosophy behind git in more detail in another article, but for now it’s enough to know that the method we’re using for backing up our projects is very well-supported in the app development world.

Creating a new account at Github is easy. You need to choose an original username, provide a valid email account to activate the Github account, and select a password. Once you’ve done that, Github will pitch you on subscribing for additional services, but you can choose the default free plan, which means only that your repositories will be publicly visible. If that’s a problem for you, you can always opt for Gitlab, which provides a free private git repository option, or pay a subscription to Github for the privilege of keeping private repos.

Ready to run?

Once you’re signed up, you’re just about ready to connect Android Studio to your Github account. We will pick that up in the next installment, and then proceed to create the most typical of all applications: the “Hello World” app. The world of Android app development is now open!

Despite what you might think, I don’t write these articles for my own well-being. I would love to hear about what kinds of app development you’re interested in doing. Your feedback will inform and influence how these articles evolve over time! If you are interested in participating, you can comment on the interactive version of ODROID Magazine for this article, or visit the ODROID Magazine forum at https://forum.odroid.com.

Be the first to comment

Leave a Reply