Skip to main content

Install Android

Minimum Requirements

  • Android Studio: Koala (or newer)
  • JDK: 17
  • Gradle: AGP 8.12.0+
  • Kotlin: 2.2.0+
  • minSdk: 26 (Android 8.0)
  • compileSdk/targetSdk: 36
  • Google Play services: required (Location, Activity Recognition)
  • Device features: GPS, Bluetooth LE, Activity sensors

Add the SDK (GitHub Packages)

Generate a Personal Access Token (classic) with read:packages, then store it safely.

github.properties (root)

gpr.usr=YOUR_GITHUB_USERNAME
gpr.key=YOUR_PERSONAL_ACCESS_TOKEN

settings.gradle / root build.gradle.kts

root/build.gradle.kts orsettings.gradle
dependencyResolutionManagement {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/AdvantaHealth/AFCore")
credentials {
username = providers.gradleProperty("gpr.usr").orNull ?: System.getenv("GPR_USER")
password = providers.gradleProperty("gpr.key").orNull ?: System.getenv("GPR_API_KEY")
}
}
google()
mavenCentral()
}
}
app/build.gradle.kts
dependencies {
implementation("com.advantahealth:core-android:<latest-release>")
}

Keep tokens out of VCS; use env vars in CI.


Initialize AFCore

Initialize once in Application (or your DI entry point).

class App : Application() {
override fun onCreate() {
super.onCreate()

val config = AFCoreConfig.builder()
.baseUrl("")
.clientId("")
.clientSecret("")
.enableLogging(true)
.logLevel(AFLogLevel.VERBOSE)
.build()

val initialized = AFCore.initialize(config)
if (initialized) {
Log.d("AFCore", "AFCore initialization succeeded")
}
}
}

Geofencing & Proximity (Background Location)

Play Console — Data safety (Background Location)

  1. Declare background location use in App content → Sensitive permissions.
  2. Provide clear in-app disclosure (why you need background location).
  3. Only request background after the user opts-in to presence features.
  4. Ensure your feature actually requires background access (geofencing/proximity).
  5. Test on real devices (OEM battery optimizations can affect geofences).

Health Tracking (Health Connect)

AFCore bundles Health Connect dependencies and permissions.

Manifest additions (required by Health Connect)

AndroidManifest.xml
<application>

<intent-filter>
<action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW_PERMISSION_USAGE"/>
<category android:name="android.intent.category.HEALTH_PERMISSIONS"/>
</intent-filter>
</application>

Play Console — Data safety (Health)

  • Declare Health data (fitness) as Collected (read-only), Not shared unless your app shares it.
  • Link your Privacy Policy; explain fitness data usage and retention.

Firebase Cloud Messaging (Push Notifications)

Add Google services plugin;

plugins { id("com.google.gms.google-services") }