Reputation: 51
I've developed an app using Android Studio and I'm currently testing it across multiple emulators with API levels ranging from 21 to 34. While the app runs without issues on API levels 26 to 34, I'm encountering a persistent problem on lower API levels (specifically 21 to 25).
I'm getting the following AccessibilityViewCheckException error, all pointing to a low contrast issue in the same view elements, which are buttons ("button1" and "button2") in an AlertDialog. Here is a snippet of the error message:
com.google.android.apps.common.testing.accessibility.framework.integrations.espresso.AccessibilityViewCheckException: There were 2 accessibility results: ...
...The item's text contrast ratio is 3.41. This ratio is based on a text color of #EC407A and background color of #323232. Consider increasing this item's text contrast ratio to 4.50 or greater.
I've recently updated all libraries and Android Studio to the latest versions. My build.gradle (:app) file looks like this:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
buildFeatures {
buildConfig = true
}
compileSdkVersion 34
defaultConfig {
applicationId "com.simplesmartappsolutions.simplestepper"
minSdk 21
targetSdk 34
// androidTest
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
}
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-TestRules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17 // JavaVersion.VERSION_11 works
targetCompatibility JavaVersion.VERSION_17 // JavaVersion.VERSION_11 works
}
namespace 'com.simplesmartappsolutions.simplestepper'
sourceSets {
main {
res {
srcDirs 'src\\main\\res', 'src\\main\\res\\xml'
}
}
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.work:work-runtime:2.9.0"
implementation 'androidx.work:work-runtime-ktx:2.9.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.mikhaellopez:circularprogressbar:3.1.0'
implementation 'androidx.test.ext:junit:1.1.5'
implementation 'androidx.test:rules:1.5.0'
// test
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
// androidTest
def testCoreVersion = "1.6.0-rc01"
androidTestImplementation "androidx.test:core:$testCoreVersion"
debugImplementation ("androidx.test:core:$testCoreVersion") {
exclude group:'androidx.test', module:'monitor'
}
// AndroidJUnitRunner and JUnit Rules
def testRunnerVersion = "1.6.0-rc01"
androidTestImplementation "androidx.test:runner:$testRunnerVersion"
debugImplementation ("androidx.test:runner:$testRunnerVersion") {
exclude group:'androidx.test', module:'monitor'
}
def testRulesVersion = '1.6.0-rc01'
androidTestImplementation "androidx.test:rules:$testRulesVersion"
debugImplementation ("androidx.test:rules:$testRulesVersion") {
exclude group:'androidx.test', module:'monitor'
}
// Espresso dependencies
androidTestImplementation "androidx.test.espresso:espresso-core:3.6.0-rc01"
// Orchestra dependencies
androidTestUtil 'androidx.test:orchestrator:1.4.2'
// UI Automator
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.3.0'
// Accessibility
androidTestImplementation "org.hamcrest:hamcrest:2.2"
androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.6.0-rc01'
// google play core
implementation 'com.google.android.play:core:1.10.3'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.android.support:appcompat-v7:$supportLibVersion"
implementation "com.android.support:recyclerview-v7:$supportLibVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.9.20"
// advertising
implementation 'com.google.android.gms:play-services-ads:23.1.0'
}
I've searched for solutions and similar issues online but haven't found anything helpful. Has anyone encountered this issue before or can suggest a solution or a workaround to avoid these AccessibilityViewCheckException errors on lower API levels?
Any help or guidance would be greatly appreciated!
Thank you.
Upvotes: 0
Views: 117