Sceneform — Set up project

Practical Guide — Part 2

This is part 2 of a series about ARCore and Sceneform using Android Studio 
In this part we will focus on the project setup

Step 1 — File → New Project

Open a new project or edit an existing one

Step 2 — Edit your Project build.gradle

Add classpath ‘com.google.ar.sceneform:plugin:[#VERSION]’ to your Project gradle file under the dependencies section. Should be similar to:

buildscript {
repositories {
google()
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.ar.sceneform:plugin:1.5.1'
}
}
...

Step 3 — Edit your App build.gradle

Add the next dependencies to App gradle under the dependencies section.
implementation “com.google.ar.sceneform:core:[#VERSION]”
implementation “com.google.ar.sceneform.ux:sceneform-ux:[#VERSION]”

In addition, make sure to apply sceneform plugin (if not applied already)
apply plugin: ‘com.google.ar.sceneform.plugin’

Should be similar to:

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:27.1.1"
...

// AR
implementation "com.google.ar.sceneform:core:1.5.1"
implementation "com.google.ar.sceneform.ux:sceneform-ux:1.5.1"
...
implementation(name: 'cameraview-library-debug', ext: 'aar')
}
apply plugin: ‘com.google.ar.sceneform.plugin’

Step 4 — Edit your AndroidManifest.xml

Add Camera permission and Camera Feature (Always needed in AR)
<uses-permission android:name=”android.permission.CAMERA” />
<uses-feature android:name=”android.hardware.camera.ar” android:required=”true” />

Under the Application section, add meta data for ARCore:
<meta-data android:name=”com.google.ar.core” android:value=”required”/>

This will makes your app available in Google Play only on devices that support ARCore. In addition, when users install an AR Required app, Google Play automatically installs ARCore. 

You can set it optional of course, Google Play will not automatically download and install ARCore when the app is installed and the app will be available in Google Play also to devices that not support ARCore.

(Anyway, your app must still perform additional runtime checks in case ARCore is later uninstalled or an updated version of ARCore is required).

Should be similar to:

Your are ready to start your first Sceneform ARCore project!
You can follow the steps for doing so in the next part