Kotlin Course With Building Android AR App - Lesson1: How to Setup Android Studio and ARCore for an Augmented Reality Project
Today we will start the Kotlin course, where we will build the Android augmented reality mobile app. As most of today’s lessons, we will learn how to setup Android Studio with ARCore for augmented reality projects.
Kotlin programming language is one of the most popular now.
Kotlin is similar to Java and strongly cooperates with that language, but I would say, Kotlin gives us much bigger opportunities.
In Kotlin, we can build not only back-end but also cross-platform mobile applications, work with data-science, do pure android development, and even do web development.
Are you ready to join the first lesson of the Kotlin course?
And if you prefer video, here is the Youtube version:
How to get Android Studio
Before we go into the coding, we need to set up an environment that we’ll use for running emulators, where we’ll be able to test our code without the need to use, real device.
We’ll use that for build application, and if we like, we can use Android Studio as a full IDE with the code editor.
We need to do it to download Android Studio with version 3.1 or higher as the first step.
Next, we need to start installing that toolset, run it, and start the configuration.
How to setup SDK
When our Android Studio launched, and we did a small overview of the IDE, we can start configuring SDK that we will use for our projects.
To go into the SDK Manager, we need to click on “Configure”, and click “SDK Manager”.
Next, we should select dependencies that should be installed.
If you have Mac OS, you need to know that versions x86_64 are not supported.
So, you need to use only x86 Android.
We will use two tabs, the first one “SDK Platforms”, where we need to check items from the list below.
- Android 8.1 (Oreo) API Level 27
- Android SDK Platform 27
- Sources for Android 27
- Google Apis Intel x86 Atom System Image
The second tab is called “SDK Tools”, where we should select items from the list below.
- Android SDK Build-Tools 30
- Android Emulator
- Android SDK Platform-Tools
- Google Play services
- Intel x86 Emulator Accelerator (HAXM installer)
How to setup AVD
When our SDK is configured, we should go into the AVD Manager.
To enter this window, we should do the same steps as with the SDK Manager, just select “AVD Manager”.
Next, we need to click on “Create Virtual Device”, and config our virtual device.
As the first step, you’ll need to select a device type you would like to have.
I’d go with the Google Pixel 2.
Next, you need to select the OS that will be installed on that device.
On mac x86_64 are not supported, you need to use x86 27 API, that we’ve already configured in the SDK Manager.
After selecting OS, you’ll come into the “verify configuration” tab.
Here you should click on the “Advanced settings”, and ensure the “back camera” field has value “VirtualScene”.
Great, your device is created!
Now, we need to run the emulator by clicking the green triangle button.
You need to wait a while(depends on your machine), and after a ~minute, you should have started a mobile device that you can use for testing and development purposes.
How to download Google Play Services for AR
We could use Google Play for that, but the easiest (and sure) way is to download APK and just install it to the device by command line.
Go to the URL
https://github.com/google-ar/arcore-android-sdk/releases and download APK file named
Save it somewhere.
How to install Google Play Services on started emulator
Now, we need to install the downloaded APK.
There are a few ways that you could do that, but I prefer the command line one.
To install that file, you need to have turned on the emulator.
Next, go into the terminal window, into the directory that contains the downloaded file, and type:
adb install -r Google_Play_Services_for_AR_1.18_x86_for_emulator.apk
How to download sample AR projects from ARCore
We are good with the Virtual Device and do not need to do config there anymore.
Let’s go into the AR projects.
For today’s lesson, we’ll use the sample projects from ARCore Android SDK.
The easiest way it’ll be to just clone the whole repository by git, open the terminal in the projects directory, and type:
git clone https://github.com/google-ar/arcore-android-sdk.git
Next, you can visit the folder, and go into the “samples” directory.
There are projects that we will run today.
Open the project
Now, you need to open the project, that we will run, like the first, test one.
We do it to see if your Android Studio is configured to run the augmented reality projects.
Of course, later will be some more config that we will be able to kick, less related to tools, more to the code that you’ll write.
Sample projects will be inside the arcore-android-sdk-1.18.0/samples
Select the “hello_ar_java” project, and open that by Android Studio.
If all is fine, you should be moved to the next step, where you will be able to add configuration or do any changes in the code.
By opening the Android Studio, the first-time app will ask you to add a configuration.
You need to click on “Add configuration”, the next module named “app” will be created.
You will use the “app”, when you run the app.
How to run the Android Studio project
Now, it’s the time for testing our config and start the fun.
When we have all configured, and we opened the project, we can run that.
To run our application, we just need to go into the “run” position of the menu, and select position “run ‘app’”.
If we have done all the setup correctly, the app should start installing it into the emulator.
When the installation is complete, we should see the screen of the working augmented reality application.
You completed the Android Studio set up of the augmented reality applications!
In the next episodes, we will be able to start with Kotlin code, I will show you how to start the Kotlin project, and we will write the first lines.
I’m super excited when thinking about possibilities that augmented reality can give us, and cannot wait to show you all of that.
Thanks for reading,
Radek from Duomly