SDK Integration
Android: SDK Integration
Overview
Add the CXR-L client library (client-l) to your Android project, configure the Maven repository and minimum SDK, and enable calls to CXRLink and related APIs.
Prerequisites
- Android Studio with Gradle Kotlin DSL or Groovy.
- Device or emulator meeting minSdk 31 (Android 12+).
- Network access to the Rokid Maven public repository.
- Rokid AI App ≥ 1.7.14 (mainland) or Hi Rokid (overseas) installed for authorization.
Repository configuration
In the root settings.gradle.kts, under dependencyResolutionManagement.repositories:
maven { url = uri(“https://maven.rokid.com/repository/maven-public/”) }
Keep google(), mavenCentral(), and other standard repositories.
Dependency declaration
In app/build.gradle.kts:
implementation(“com.rokid.cxr:client-l:1.0.3”)
Application and global link
Reuse a single CXRLink instance for the session lifecycle. Hold it in your Application class:
class MyApplication : Application() {
var sharedLink: CXRLink? = null
fun resetSession() {
sharedLink = null
}
}
Register in AndroidManifest.xml:
<application android:name=”.MyApplication” …>
Note: Your namespace / applicationId is unrelated to the glasses-side target package used in CUSTOMAPP sessions.
Permissions and manifest (required)
| Permission | Required | Purpose |
|---|---|---|
INTERNET | Yes | SDK network communication |
MANAGE_MEDIA | Recommended | Media/file access (declared in Sample) |
MANAGE_EXTERNAL_STORAGE | For public APK path on API 30+ | Read cxrL.apk from public storage |
READ_EXTERNAL_STORAGE (maxSdkVersion=32) | For API ≤32 public paths | Read external storage |
Before appUploadAndInstall, verify the APK file is readable; for public paths grant all-files access (API 30+) or READ_EXTERNAL_STORAGE. Prefer app-specific dirs (getExternalFilesDir). Sample uses ApkInstallAccess.
For sharing local files (e.g. WAV audio), configure FileProvider with authority ${applicationId}.fileprovider.
Glasses-side: CXR-S SDK integration
Add the CXR-S client library (Maven artifact cxr-service-bridge) to a glasses-side Android project for CXRServiceBridge and Caps. Phone apps use client-l above; do not add cxr-service-bridge to the phone app.
Dependency
In glasses app/build.gradle.kts:
implementation(“com.rokid.cxr:cxr-service-bridge:1.0-20260417.063502-103”)
Version note: Example uses the CXRSWithCXRLSample snapshot coordinate; follow the Sample
build.gradle.ktsand release notes for production.
AndroidManifest
CXRSWithCXRLSample keeps the manifest minimal:
- Entry
MainActivitywithandroid:exported=“true”. - No extra CXR permissions; leg/touchpad broadcasts are registered at runtime via
registerReceiver.
<application …>
<activity
android:name=“.activities.main.MainActivity”
android:exported=“true”
…>
<intent-filter>
<action android:name=“android.intent.action.MAIN” />
<category android:name=“android.intent.category.LAUNCHER” />
</intent-filter>
</activity>
</application>
Initialization timing
After the phone starts your app via appStart:
setStatusListener(StatusListener)— connection state.subscribe(clientKey, MsgCallback)— phone → glasses command channel.
See Custom Commands chapter. Sample does both in MainViewModel.init.
Constraints
applicationIdmust match phoneCUSTOMAPP.packageName.- Keep SDK versions compatible across phone, glasses, and OS when upgrading.
Appendix: Sample
CXRSWithCXRLSample: app/build.gradle.kts (minSdk = 31, dependency), app/src/main/AndroidManifest.xml.
Sync and verification
- Gradle Sync completes without dependency errors.
import com.rokid.cxr.link.CXRLinkresolves in source files.
Next steps
Continue with authentication to obtain a token, then connection and session.
Appendix: reference sample
RenewCXRLSample (com.rokid.renewcxrlsample) demonstrates settings.gradle.kts, app/build.gradle.kts, and CXRLApplication.kt. The sample may use a different SDK version — use 1.0.3 from this doc for integration.