Android Studio ARExample with Source Code

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,
  1. Open Android Studio
  2. Create a new Project
  3. Enter the name of the project
  4. Select an Empty Activity
  5. Click Finish.
  6. 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
  <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:

  1. Open you Emulator and make sure you have selected a device with 8.1 version image.
  2. Click on 3dots
  3. Click on settings -> Advance -> Under OpenGL API level -> Select Renderer maximum(OpenGL ES 3.1)
  4. 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.

Download Source Code!
password: justblink



Comments