Hey, guys in this video I'm going to tell you about how you can use Augment Reality in your android studio project, so let's get started.
Firstly,
- Open Android Studio
- Create a new Project
- Enter the name of the project
- Select an Empty Activity
- Click Finish.
- Wait for your gradle to build.
*Open you App Gradle File and include the dependencies as shown in the image and click sync, Wait for your project to build.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//dependency
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.8.0'
//sceneformasset
sceneform.asset('sampledata/ArcticFox_Posed.obj',
'default',
'sampledata/ArcticFox_Posed.sfa',
'src/main/assets/ArcticFox_Posed')
*Open your manifest file and include the meta tag and required permissions.
//permissions
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera.ar" android:required="true"/>
//meta-tag
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera.ar" android:required="true"/>
//meta-tag
<meta-data android:name="com.google.ar.core" android:value="required" />
*Create a Sample data directory and paste you 3D poly object file(you can download your desired poly model from poly.google.com). Right-click on your 3D model OBJ file and select import Sceneform Asset and wait for you gradle to build. After that, your 3D model will appear on the screen.
*Open the MainActivity.XML insert ARfragment in it.
*Open MainActivity.java file and paste the codes(contain in the source code file) in your java file.
Testing On Emulator:
- Open you Emulator and make sure you have selected a device with 8.1 version image.
- Click on 3dots
- Click on settings -> Advance -> Under OpenGL API level -> Select Renderer maximum(OpenGL ES 3.1)
- You have to download and install the ARCore App in order to run your app.
And that's it. Here is your First AR app in android studio.
Comments
Post a Comment