Skip to main content

Android SDK

Overview

The WAS VPS Android SDK ships with Sceneform fragments and lifecycle helpers so you can localize users inside VPS maps on ARCore-enabled devices. Follow the Immersal-style flow: confirm prerequisites, install the dependency, prepare the manifest, and start the service.

Prerequisites

  • Minimum Android SDK 24 (Android 7.0)
  • Device with ARCore support
  • Project configured with Kotlin (samples are Kotlin-first)

Need an API key? Grab one at space.web-ar.studio or email support@webar3.com / support@web-ar.studio.

Install the SDK

  1. Ensure the project resolves artifacts from Maven Central:

    allprojects {
    repositories {
    mavenCentral()
    // other repositories...
    }
    }
  2. Add the dependency to your app module:

    dependencies {
    implementation "com.arstudio:wasvps-sdk:1.0.0"
    }
  3. Sync Gradle.

Manifest Setup

Declare ARCore requirements and override the minimum SDK if needed:

<!-- Allow WASVPS SDK on minSdk < 24 -->
<uses-sdk tools:overrideLibrary="com.arstudio.wasvps_sdk, com.google.ar.sceneform.sceneform, com.google.ar.sceneform.ux" />

<!-- Restrict to ARCore hardware (default). Set required=false to broaden install base. -->
<uses-feature
android:name="android.hardware.camera.ar"
android:required="true" />

To relax the Play Store device filter, set android:required="false" and keep the existing tools:replace="android:required" attribute.

Quick Start with WASVPSArFragment

Host the provided fragment inside your layout:

<!-- res/layout/activity_main.xml -->
<androidx.fragment.app.FragmentContainerView
android:id="@+id/vFragmentContainer"
android:name="com.arstudio.wasvps_sdk.ui.WASVPSArFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

supportFragmentManager.beginTransaction()
.replace(R.id.vFragmentContainer, WASVPSArFragment())
.commit()
}
}

Access the service and start localization when you have location IDs:

val fragment = supportFragmentManager
.findFragmentById(R.id.vFragmentContainer) as WASVPSArFragment

val config = WASVPSConfig.getIndoorConfig(listOf("your-location-id"))
val service = fragment.vpsService

service.setVpsConfig(config)
service.setVpsCallback(object : VpsCallback {
override fun onSuccess() = Unit
override fun onFail() = Unit
override fun onStateChange(state: State) = Unit
override fun onError(error: Throwable) {
Log.e("VPS", "Localization error", error)
}
})

service.startVpsService()

Call service.stopVpsService() when the AR experience should pause (e.g., in onPause).

Custom Fragment Integration

For projects with a custom ArFragment or ArSceneView, create and manage WASVPSService yourself:

class CustomArFragment : ArFragment() {
private val vpsService = WASVPSService.newInstance()

override fun onAttach(context: Context) {
super.onAttach(context)
WASVPSSdk.init(context.applicationContext)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
vpsService.bindArSceneView(arSceneView)
vpsService.setVpsConfig(WASVPSConfig.getOutdoorConfig(listOf("location-id")))
}

override fun onResume() {
super.onResume()
vpsService.resume()
vpsService.startVpsService()
}

override fun onPause() {
vpsService.pause()
vpsService.stopVpsService()
super.onPause()
}

override fun onDestroyView() {
vpsService.destroy()
super.onDestroyView()
}
}

Anchoring Content

Place nodes relative to vpsService.worldNode. Any child added to that node automatically follows the localized global transform once VPS succeeds.

val anchorNode = Node().apply {
setParent(vpsService.worldNode)
localPosition = Vector3(0f, 0f, -1f)
}

Troubleshooting

  • Ensure Google Play Services for AR is installed and updated on the test device.
  • If localization never succeeds, verify the API key assigned to the SDK (via secure config) and confirm your location IDs exist.
  • Review the /sample module in the repository for end-to-end usage, including runtime permission handling and UI.