Skip to Content
SDKSDKsXenseAR Native SDKFlutterInstall XenseAR SDK for Flutter (Android)

XenseAR SDK Integration Guide for Flutter Android

Prerequisites

  1. Download the Template Project from the Downloads page.
  2. Download the corresponding SDK from the Downloads page.
  3. Prepare the Flutter project that you want to integrate with XenseAR.

Integration Steps

1. Run the Template Project to understand how the SDK works

Run the following command in the terminal:

flutter run

2. Create a libs folder in <flutter root>/android/app/, then copy the following files from the SDK:

  • unityLibrary-release.aar
  • All files inside the libs folder

3. Modify <flutter root>/android/app/build.gradle.kts

Note: Depending on your project’s configuration, you may need to adapt the syntax accordingly.

// ... android { // ... ndkVersion = "27.2.12479018" defaultConfig { // ... minSdk = 26 targetSdk = 35 } buildTypes { release { // ... isMinifyEnabled = false isShrinkResources = false } } } dependencies { implementation(fileTree(mapOf( "dir" to "libs", "include" to listOf("*.aar") ))) } // ...

4. Add the following content to <flutter root>/android/app/src/main/res/values/strings.xml

<resources> <!-- ... --> <string name="game_view_content_description">GameView</string> </resources>

5. Modify <flutter root>/android/build.gradle.kts

Note: Depending on your project’s configuration, you may need to adapt the syntax accordingly.

allprojects { repositories { // ... flatDir { dirs("libs") } } } // ...

6. In the folder containing MainActivity.kt, create the following files:

  • MainUnityActivity.kt
  • XenseAREventManager.kt
  • XenseARManager.kt

Then copy the implementations from the Template Project for:

  • MainActivity.kt
  • MainUnityActivity.kt
  • XenseAREventManager.kt
  • XenseARManager.kt

7. Update AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application <!-- ... --> <activity android:name="<your-app-namespace>.MainUnityActivity" android:label="@string/app_name" android:screenOrientation="fullSensor" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density" android:hardwareAccelerated="true"> </activity> <!-- ... --> </application> <!-- ... --> </manifest>

8. After completing the steps above, continue to the Usage page to learn how to use the SDK in your Flutter application.

Last updated on