Using the Android Integration (beta)
Use this integration to get Android accessibility results into the Stark dashboard
With Stark's Android integration, you can unlock deeper accessibility scans and get your results to show up in the Stark dashboard alongside your other assets.
Using the Android Integration
Prerequisites
Ensure your project has Maven Central configured in both your settings.gradle
(or settings.gradle.kts
) and root build.gradle
files:
In settings.gradle
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
google()
}
}
dependencyResolutionManagement {
repositories {
mavenCentral()
google()
}
}
Or in your root build.gradle
if not using dependency resolution management:
allprojects {
repositories {
mavenCentral()
google()
}
}
Apply the Stark Accessibility plugin to your app's build.gradle
file:
plugins {
id 'co.getstark.accessibility' version '1.0.1'
}
stark {
starkToken = "your-stark-project-token"
}
Or if using Kotlin DSL (build.gradle.kts
):
plugins {
id("co.getstark.accessibility") version "1.0.1"
}
stark {
starkToken.set("your-stark-project-token")
}
That's it! The plugin automatically adds the necessary dependencies:
- Lint rules for build-time accessibility checks - makes it so Stark can analyze your XML layouts and detect accessibility issues. The best way to check your code as it includes more than 70 built-in Stark checks.
- Instrumentation library for runtime accessibility testing - scans your actual running app during instrumentation tests and surfaces any accessibility issues from Google's Accessibility Test Framework.
Usage
Lint Checks
Once the plugin is applied, Stark's accessibility checks are automatically included in your project's lint process. The plugin also creates tasks for each build variant to upload lint results to Stark.
# Run lint checks (includes Stark's accessibility rules)
./gradlew lint
# Run lint and upload results to Stark
./gradlew starkAccessibilityCheckDebug
Instrumentation Testing
For runtime accessibility testing, use the AccessibilityChecker
in your instrumentation tests:
@RunWith(AndroidJUnit4.class)
public class AccessibilityTest {
@Test
public void testMainActivityAccessibility() {
try (ActivityScenario scenario = ActivityScenario.launch(MainActivity.class)) {
scenario.onActivity(activity -> {
View rootView = activity.getWindow().getDecorView().getRootView();
AccessibilityChecker checker = new AccessibilityChecker("your-stark-project-token");
CompletableFuture> resultsFuture = checker.runStandardChecks(rootView, "MainActivity Scan");
try {
resultsFuture.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
}
}
Bringing scan results into Stark
- Log into your Stark account
- Click
Create a Project
- Scroll to
Add Android app
- Copy the Stark token shown into the
starkToken
field mentioned above - Provide a
Name
for easy reference when viewing all of your assets - Run the integration tests or lint targets in Android Studio to see your results show up in Stark
Running checks in your CI/CD
You can run the Stark tasks in your CI/CD. An example using GitHub actions is shown below:
name: Stark Accessibility Scan
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
run-command:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Stark accessibility scan
run: |
echo "Running Stark accessibility scan..."
./gradlew starkAccessibilityCheckRelease
Have any questions about using Stark's developer tools? Don’t hesitate to reach out to us at support@getstark.co.