XenseAR SDK Integration Guide for Flutter Android
Prerequisites
- Download the Template Project from the Downloads page.
- Download the corresponding SDK from the Downloads page.
- 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 run2. Create a libs folder in <flutter root>/android/app/, then copy the following files from the SDK:
unityLibrary-release.aar- All files inside the
libsfolder
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.ktXenseAREventManager.ktXenseARManager.kt
Then copy the implementations from the Template Project for:
MainActivity.ktMainUnityActivity.ktXenseAREventManager.ktXenseARManager.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.