Quickstart in Android Kotlin
Integrate the ARwayKit SDK with Android Kotlin
In this quickstart guide, we will be integrating the ARwayKit SDK with Android Kotlin. This example will be using Unity as a Library to integrate into an Android app.
Installed Versions
In this guide, we will be using the following versions:
Android Studio: 2022.1.1
Unity: 2022.3.29f1 LST
Android Min API Level 24
Download the ARwayKit SDK
Steps
Download the ARwayKit SDK project from GitHub as a ZIP. You can contact us for access to the ARwayKit SDK.
Create a Basic Project in Android Studio
Create a new sample Android Project, for this example a new project using the Empty Activity template will be used with the language set to Kotlin and the minimum SDK set to API 24.
Generate the Gradle Project for the Android Platform
Build Steps
In Unity select File -> Build Settings.
Switch the Platform to Android.
Select option "Export Project".

Export the project. Export the ARwayKit Unity SDK to a new folder and name it "androidBuild" and place it in the base directory for the Android Kotlin project.
Add the Unity Android Build to the Android App
Steps
Open the Android sample app in Android Studio.
Open the
settings.gradlefile and make the following changes to the code as shown below. Ensure that the line'androidBuild\\unityLibrary'matches the path to the ARwayKit Unity SDK export.Open
build.gradle(Module: app) file, then add the following in the dependencies block.Open
gradle.propertiesand add the code below to the end of the file.In the file /app/src/main/AndroidManifest.xml add
tools:replace="android:allowBackup"to line 6.You will be notified that changes have been made to the grade files, click the 'Sync Now' button to continue.

Sync the gradle files. If everything succeeds you should be able to see the unityLibrary module added in the Android view.
Preparing the Sample Project
To run the ARwayKit Unity SDK on Android, we need to integrate Unity as a library in our Android project. This will allow us to use the Unity engine within our app and run Unity scenes alongside native Android activities. In this section, we will go through the steps to set up Unity as a library and add the ARwayKit Unity SDK to the project.
For this we will be creating a new blank Activity in the project called
MainUnityActiviy. Make sure the generate the layout file as well.
In the above file, the addControlsToUnityFrame() method sets the positions of the buttons added to the layout. These buttons are not required but showcase the methods to unload the Unity player.
To pass data to Unity, you can call the following method:
The
MainActivity.ktfile will be modified to add a button to load the activity above. The code below shows the end result.
Next, find the newly created layout file under
src/main/res/layoutcalledactivity_main_unity.xml. This adds the buttons to open the Unity activity and close the app.
Modify the layout code of the default file
activity_main.xmlto load theactivity_main_unity.xmlfile from above.
Then add a new string resource with the name
game_view_content_descriptionand the contentGame viewin thestrings.xmlfile.
Once you have completed all the necessary steps to integrate the ARwayKit Unity SDK into your Android Kotlin project, you are ready to build, run, and debug your app. If everything has been properly configured, you should be able to run the app seamlessly with the ARwayKit Unity SDK.
Unity will run in another process android:process=":Unity" (AndroidManifest.xml at app module).
Last updated