This file provides guidance to coding agents when working with code in this repository.
Android SDK for Gravatar — provides avatar URL generation, profile fetching/updating, avatar management, and ready-made Compose UI components (profile cards, Quick Editor). Published to Maven Central.
- gravatar — Core SDK: avatar URLs, REST API client (OpenAPI-generated), profile/avatar services, OkHttp networking with Moshi serialization. See Core Module Usage.
- gravatar-ui — Compose UI components: profile cards, avatar views (depends on
gravatar). See UI Module Usage. - gravatar-quickeditor — Drop-in Compose profile editor with OAuth, image cropping, avatar selection (depends on
gravatar+gravatar-ui). See Quick Editor Module Usage. - demo-app — Sample application showcasing SDK features
- uitestutils — Shared test utilities for screenshot tests
For installation, API key setup, and general usage, see Get Started.
./gradlew assembleDebug # Build all modules
./gradlew testDebugUnitTest # All unit tests
./gradlew lintDebug # Android lint
./gradlew detekt # Static analysis (excludes generated restapi code)
./gradlew ktlintCheck # Code formatting check
./gradlew ktlintFormat # Auto-fix formatting issues
./gradlew apiCheck # Binary compatibility validation
./gradlew apiDump # Generate/update .api files after public API changesScreenshot tests (Roborazzi):
./gradlew :gravatar-ui:verifyRoborazziDebug -Pscreenshot
./gradlew :gravatar-quickeditor:verifyRoborazziDebug -Pscreenshot
./gradlew :gravatar-ui:recordRoborazziDebug -Pscreenshot # Record new baselines
./gradlew :gravatar-quickeditor:recordRoborazziDebug -PscreenshotRun a single test class:
./gradlew :gravatar:testDebugUnitTest --tests "com.gravatar.AvatarUrlTest"OpenAPI code generation:
./gradlew :gravatar:openApiGenerateFor an in-depth overview of the SDK's inner workings, design decisions, and implementation details, see SDK Technical Details.
Composite build with convention plugins in build-logic/:
gravatar.android.library— shared Android library config (min/target SDK, Kotlin, detekt, ktlint)gravatar.android.compose— Compose compiler and Roborazzi setupgravatar.openapi.generator— OpenAPI code generation for REST API models/clientsgravatar.maven.publish— Maven Central publishing via Vanniktech plugin
The gravatar/src/main/java/com/gravatar/restapi/ package is auto-generated from an OpenAPI spec via openApiGenerate. Do not edit these files manually. Key generated components:
apis/ProfilesApi,apis/AvatarsApi— API endpoint definitionsmodels/— Data models (Profile, Avatar, etc.)infrastructure/— HTTP client infrastructure (ApiClient, Serializer)
Hand-written service classes in gravatar/src/main/java/com/gravatar/services/ wrap the generated API:
ProfileService— Profile fetching and updatingAvatarService— Avatar upload and managementGravatarResult— Sealed result type for API responses
Gravatar.kt is the entry point — configures API key and OkHttp client. Uses GravatarSdkContainer for manual dependency injection.
SDK version is derived from git describe --tags. Non-tag builds append -SNAPSHOT. The version is injected as BuildConfig.SDK_VERSION in the gravatar module.
- JUnit 4 + Robolectric for unit tests needing Android resources
- MockK for mocking
- Turbine for Flow testing
- MockWebServer for HTTP testing
- Roborazzi for screenshot/snapshot tests (modules:
gravatar-ui,gravatar-quickeditor) - Unit tests use
kotlin.testassertions (assertEquals,assertNotNull, etc.) — not AssertJ - Test names use backtick format with descriptive names
- Generated code is checked in: The
restapi/package undergravataris committed to the repo. RunopenApiGenerateto regenerate, but don't hand-edit those files. See OpenAPI generation for details on templates and customization. - Screenshot test baselines: Must pass
-Pscreenshotflag for Roborazzi tasks. Baselines live ingravatar-ui/screenshotTests/roborazzi/andgravatar-quickeditor/screenshotTests/roborazzi/. - Binary compatibility: Public API changes require running
./gradlew apiDumpto update.apifiles. CI enforces compatibility viaapiCheck. - Explicit API mode: Enabled in strict mode for library modules — all public declarations require explicit visibility modifiers. See Explicit API mode.
secrets.properties: Required for the demo app but managed via.configure— never commit actual secrets.