Exploring The Android ARCore
Augmented Reality (AR) is a live direct or indirect view of a physical, real-world environment whose elements are “augmented” by computer-generated or extracted real-world sensory input such as sound, video, graphics or GPS data. It is related to a more general concept called computer-mediated reality, in which a view of reality is modified (possibly even diminished rather than augmented) by a computer.
Here is a show case, Invisible Highway:
Check out more cool AR experiments.
What is ARCore?
As an Android Engineer, I was struggle to find an official device independent augmented reality SDK for Android. I need to use third party library such as Vuforia. Previously, The only official Google project for AR is Tango; but it can be used only for Tango Devices.
Finally, Google released an augmented reality SDK called ARCore. It was built on top of Tango, but it is devices independent (Not entirely the case but good initiative), so it can scale across the Android ecosystem. Still currently you need to have one of these supported devices:
- Google Pixel and Pixel XL
- Samsung Galaxy S8 (SM-G950U, SM-G950N, SM-G950FD, SM-G950FD, SM-G950W, SM-G950U1)
Note: Samsung Galaxy S8+ is not supported (Weird)
:) Big Note: ARCore is currently in preview. There may be breaking changes before the 1.0 release.
Sample Application
In getting started page for Android, Google provided a sample application whose functions are automatically detects flat surfaces when user move devices and draws a diamond grid; then if user tap once on the grid, it places an Android robot on the surface.
Here are few thing I encountered when try out the sample:
- If you run on unsupported device there will be an popup message:
“This device does not support AR”
- You will need to get the ARCore SDK for Android Studio. You can either:
Download the SDK preview for Android Studio and extract it.
-or-
Clone the repository with the following command:
git clone https://github.com/google-ar/arcore-android-sdk.git
And if you build the sample application, you might get following error:
java.lang.UnsatisfiedLinkError: No implementation found for int com.google.atap.tango.TangoJNINative.Initialize(android.content.Context) (tried Java_com_google_atap_tango_TangoJNINative_Initialize and Java_com_google_atap_tango_TangoJNINative_Initialize__Landroid_content_Context_2)
How can we resolve this?
An eye catchy word in the error is Tango; remember when I mentioned ARCore was built on top of Tango. We need to install arcore-preview.apk which contains the tango package to our devices using adb.
adb is located in platform-tool of your Android sdk, so locate where your adb is and install the arcore-preview.apk using:
./adb install -r -d path_to_arcore-preview.apk
To verify; you can run below command
./adb shell 'pm list packages -f' | grep tango
What the command does is to show all the package and narrow it to only those contain tango word. Then, you should see following package if the apk was installed correctly.
package:/data/app/com.google.tango-2/base.apk=com.google.tango
Now run sample application again; it should be working. Here is a demo that I tried out.