Android Troubleshooting
Solutions to common build, runtime, and integration issues with the SmartSpectra Android SDK.
Set minSdk 28 in your app/build.gradle:
android {
defaultConfig {
minSdk 28
}
}SmartSpectra 3.2.x requires compileSdk 36.1 or later. Update your app module
and Android build tooling, then sync Gradle again:
android {
compileSdk = 36
compileSdkMinor = 1
}Use AGP 8.10.1 or later and Kotlin 2.2.x. If your project uses Gradle 9, use an AGP 9.x release. See Option 1: API Key for the complete compatible toolchain.
The quickstarts extend ComponentActivity, which comes from
androidx.activity:activity-ktx. Confirm that dependency is declared, then check
the imports in your activity file:
import android.os.Bundle
import androidx.activity.ComponentActivity
import com.presagetech.smartspectra.SmartSpectraSdkIf you are following older material that used AppCompatActivity, either switch to
ComponentActivity or add androidx.appcompat:appcompat yourself — the SDK does not
pull it in.
Remove icon references from AndroidManifest.xml or add the missing drawable resources. A minimal application tag that avoids this:
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Material3.DayNight">- Clean Project — Build → Clean Project
- Rebuild — Build → Rebuild Project
- Sync Gradle — File → Sync Project with Gradle Files (or the elephant icon in the toolbar)
- Invalidate Caches — File → Invalidate Caches and Restart
If the R class stops resolving in the linter, Sync Project with Gradle Files typically fixes it.
The host app is responsible for requesting Android's runtime camera permission
before calling sdk.start(). The SDK does not show the permission dialog itself.
Common causes:
- Testing on an emulator — a physical device with a working camera is required.
- Permission was previously denied — guide the user to re-enable camera access in system Settings.
start()was called before permission was granted — observesdk.errorforSmartSpectraError(code = INPUT_UNAVAILABLE, retryable = true).
Because the host app owns the permission prompt, keep the rationale string in your app resources and show it from your onboarding or permission UI:
<string name="camera_permission_hint">Your custom message explaining why camera access is needed.</string>Request camera permission with the modern ActivityResultLauncher pattern:
import android.Manifest
import android.content.pm.PackageManager
import android.os.Bundle
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.launch
private lateinit var requestCameraPermission: ActivityResultLauncher<String>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestCameraPermission = registerForActivityResult(
ActivityResultContracts.RequestPermission()
) { granted ->
if (granted) startMeasurement()
}
}
private fun startMeasurement() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED
) {
requestCameraPermission.launch(Manifest.permission.CAMERA)
return
}
lifecycleScope.launch {
sdk.start()
}
}If start() is called without permission, the SDK publishes a
SmartSpectraError(code = INPUT_UNAVAILABLE, retryable = true) to sdk.error.
Observe that error to surface recovery UI and retry after the user grants access.
- Verify the API key string is correct in your code.
- Confirm your subscription is active at physiology.presagetech.com.
- Check that the device has an active internet connection — the SDK requires network access for subscription validation.
Android OAuth is currently documented for Play Store releases only. For local development, internal QA, or sideloaded debug builds, use an API key instead.
If you're preparing a Play Store release, register the SHA-256 fingerprint for the signing certificate used by that release, then re-download presage_services.xml.
Run:
keytool -list -v -keystore <path-to-keystore> -alias <key-alias> -storepass <store-password> | grep SHA256Register that fingerprint under Account → OAuth Registration alongside your package name, then re-download and replace presage_services.xml.
Note: Each package name can only be registered once. You cannot create multiple OAuth configs for the same package name.