How to Create an ARCore App Using Kotlin

BLOG by 

February 10, 2020

This is a step-by-step guide for creating a basic ARCore app with Kotlin using Android Studio, with a little bit of an Introduction on ARCore and Kotlin. We start with knowing what ARCore is, moving to Kotlin and then the tutorial. In the end we compiled some questions to explore what a developer’s perspective would be on ARCore and Kotlin.

What is ARCore

ARCore is a software development kit (SDK) by Google. It is a developer’s tool for creating augmented reality apps on Android.

But it doesn’t end at that. In fact, there are many sequels to it. Not too long ago – Feb’ 6th of 2020 to be exact – version 1.15.0 of ARCore was released by Google. What does this latest launch mean?

It means that now some of the devices will now be able to support some additional and exciting features. For instance, some devices will be able to yield new supported camera configs and that too with a GPU texture resolution lower than that of the device’s default GPU texture resolution.

Exciting right?
With previous versions there were some limitations involved but Google is known to ‘always’ have some neat tricks up its sleeve and never disappoints.

Now, if you are hearing the word ‘ARCore’ for the first time, let me shine some light on the matter.

A Walk Down the Memory Lane

For Google to jump the AR bandwagon and be able to compete with Apple on their Augmented Reality platform (ARKit), something big was missing. Tango was the initial intended AR breakthrough for Google, but didn’t quite pan out that well.
To fill this void, Google created ARCore, a competitor to ARKit, by using data from the Tango Project, and today it’s doing better than great.

Apps like Pokemon Go and IKEA Palace are prime examples of what augmented reality apps look like.

If you want to know more about Google’s ARCore, check out this article here.

Why Use Kotlin with ARCore

Kotlin is a statically typed programming language that runs on a Java Virtual machine (JVM). It is an officially supported programming language on Android Studio 3.0 or above besides Java.

So what makes Kotlin so exciting as a new language and that too, why try it out with ARCore?

  1. Because it’s new, and we are always excited about trying new tech, finding better and innovative ways of doing things.
  2. Kotlin has some really amazing features like the inbuilt ‘null safety’ – Goodbye Null pointer exceptions!
  3. The code is so concise! Compare java code with Kotlin code and you will see the difference.

These are just a few reasons that surfaced at the top of my mind and should be enough to get you started on a Kotlin-fied Augmented Reality journey.

Before we begin, lets find out:

What Do You Need To Get Started With ARCore Using Kotlin

First thing is first, you need Android studio 3.0 or above – because this version of Android has full support for Kotlin. You might get lucky with Android 2.3.3 but you will have to download the Kotlin plug-in yourself and test your luck.

We tested with Android 3.0.1 but it did not have emulator support for ARCore. So we tried 3.1 beta 4 version and it worked perfect with the ARCore sample app running on a virtual Pixel device. (Read ahead to know why you would need an emulator and a virtual device).

Also, we used to a Mac device to create this tutorial, things will be a little different on a windows based device.

If you have Andoid Studio installed on your machine, skip the following steps.

Step 1: Locate Downloaded file on your System

Step 2: Run the file and wait for the setup to finish.

Step 3: You should be prompted with this screen.

Step 4: Click Android Studio and you should arrive at Android Setup Wizard. Let it download the required SDK components.

Step 5: Choose the Installation type

It is best to go with the standard option, unless you REALLY know what you want in your Android Studio, because if you don’t then this will become a huge nuisance when you start to develop.

Step 6: Choose Your UI – This is just the look and theme of your Android Studio. You can even change this after the installation is complete.

Step 7: Let the Android magic begin – Note: You might be prompted to let Android change some setting, just type in your password and open security preferences for Android.

Congratulations! You have successfully downloaded and Installed Android Studio on your device.

Download ARCore SDK for Android Studio

ou can either download it from google or clone the repository from Github. You need this SDK for utilizing AR elements and features.So you will download this on your device.

Step 1: Search for ‘ARCore’ and you will see Google’s Official ARCore page.

Step 2: Find Resources and click on the downloads option.

Step 3: Donwload ARCore SDK for Android Studio.

If you want to clone it from Github – Follow on till step 2 and click on the Github link.

And now to the bane of all that is ARCore.

For creating an augmented reality app, you need an ARCore supported smartphone.

Google, originally, limited ARCore to a handful of Google pixel and Samsung galaxy smartphones BUT promised to bring ARCore to a million Android devices soon.

The promise of ‘SOON’ was met at the Mobile World Congress and the ‘million devices’ so to speak, boiled down to a few more handful devices.

Following is the list of ARCore supported devices.

Google Phones

  • Pixel
  • Pixel XL
  • Pixel 2
  • Pixel 2 XL

Samsung Phones

  • Galaxy S8
  • S8+
  • Note8
  • S7 edge

LG Phones

  • V30
  • V30+ (Android O only)

Asus Phones

  • Zenfone AR

OnePlus Phones

  • OnePlus 5

If you don’t have one of the above mentioned devices, here are two ways you can work this around.

Try following this guide on how to use ARCore on unsupported devices OR Run your app in an emulator.

Here is How you setup an Emulator in Android Studio

Step 1: Find ‘Preference’ option.