When i am trying to run UI Test Cases in android studio they are working perfectly but when tried running in circleci i am facing issues.
Job i created was for UI Testing
android-test:
working_directory: ~/code
executor:
name: android/android-machine
resource-class: large
tag: 2021.10.1
environment:
JVM_OPTS: -Xmx2048m
GRADLE_OPTS: -Xmx1536m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false
steps:
- checkout
- *cache_restore
- create-gradle-file
- android/start-emulator-and-run-tests:
system-image: system-images;android-30;google_apis;x86
test-command: ./gradlew --init-script circleci.gradle connectedDebugAndroidTest
- *cache_save
- store_artifacts: # for display in Artifacts: Storing Build Artifacts - CircleCI
path: app/build/reports
destination: reports
- store_test_results: # for display in Test Summary: Collecting test data - CircleCI
path: app/build/test-results
Output i noticed was
#!/bin/bash -eo pipefail
run_with_retry() {
MAX_TRIES=2
n=1
until [ $n -gt $MAX_TRIES ]
do
echo "Starting test attempt $n"
./gradlew --init-script circleci.gradle connectedDebugAndroidTest && break
n=$[$n+1]
sleep 5
done
if [ $n -gt $MAX_TRIES ]; then
echo "Max tries reached (2)"
exit 1
fi
}
run_with_retry
Starting test attempt 1
<-------------> 0% INITIALIZING [27ms]
<-------------> 0% CONFIGURING [127ms]> root project > Resolve files of :classpath<======-------> 50% CONFIGURING [227ms]> :app<======-------> 50% CONFIGURING [327ms]<======-------> 50% CONFIGURING [427ms]> :app > Resolve dependencies of :app:_agp_internal_javaPreCompileRelease_kaptC<======-------> 50% CONFIGURING [527ms]> :app > Resolve dependencies of :app:debugAndroidTestImplementationDependencie<======-------> 50% CONFIGURING [627ms]> :app<======-------> 50% CONFIGURING [727ms]> :app > Resolve dependencies of :app:debugImplementationDependenciesMetadataCo<======-------> 50% CONFIGURING [827ms]> :app > Resolve dependencies of :app:debugRuntimeElementsCopy<======-------> 50% CONFIGURING [927ms]> :app > Resolve dependencies of :app:implementationDependenciesMetadataCopy<======-------> 50% CONFIGURING [1s]> :app > Resolve dependencies of :app:kaptTestDebugCopy> :app > Resolve dependencies of :app:releaseRuntimeClasspathCopy> :app > Resolve dependencies of :app:releaseRuntimeElementsCopy> :app
> Configure project :app
Disable pre dexing for module app
WARNING:DSL element 'dexOptions' is obsolete and should be removed.
It will be removed in version 8.0 of the Android Gradle plugin.
Using it has no effect, and the AndroidGradle plugin optimizes dexing automatically.
<=============> 100% CONFIGURING [1s]> IDLE<-------------> 4% EXECUTING [1s]> :app:dataBindingMergeDependencyArtifactsDebug > Resolve dependencies of :app:<=------------> 8% EXECUTING [1s]> :app:injectCrashlyticsMappingFileIdDebug<===----------> 23% EXECUTING [1s]> :app:kaptGenerateStubsDebugKotlin > Resolve files of :app:debugCompileClasspa<===----------> 23% EXECUTING [2s]> :app:kaptGenerateStubsDebugKotlin<===----------> 24% EXECUTING [2s]> :app:kaptDebugKotlin<====---------> 32% EXECUTING [2s]> :app:dataBindingMergeDependencyArtifactsDebugAndroidTest > Resolve dependenci<=====--------> 40% EXECUTING [2s]> :app:dataBindingGenBaseClassesDebugAndroidTest<======-------> 49% EXECUTING [2s]> :app:javaPreCompileDebugAndroidTest > Resolve dependencies of :app:_agp_inter<=======------> 55% EXECUTING [2s]> :app:mergeDebugAssets<=======------> 55% EXECUTING [3s]<=======------> 56% EXECUTING [3s]> :app:compressDebugAssets
> :app:l8DexDesugarLibDebug
<=======------> 57% EXECUTING [3s]> :app:mergeDebugJavaResource<=======------> 57% EXECUTING [4s]
> :app:checkDebugDuplicateClasses<=======------> 58% EXECUTING [4s]> :app:desugarDebugFileDependencies > Resolve files of :app:debugRuntimeClasspa<=======------> 59% EXECUTING [4s]> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath > Resolve> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath > Resolve> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath<=======------> 59% EXECUTING [5s]> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath > Resolve> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath > Resolve> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath<=======------> 59% EXECUTING [6s]> :app:mergeExtDexDebug<=======------> 59% EXECUTING [7s]<========-----> 61% EXECUTING [7s]> :app:transformDebugClassesWithAsm<========-----> 61% EXECUTING [8s]<========-----> 64% EXECUTING [8s]> :app:mergeDebugNativeLibs<========-----> 64% EXECUTING [9s]<========-----> 64% EXECUTING [10s]<========-----> 64% EXECUTING [11s]<========-----> 64% EXECUTING [12s]<========-----> 64% EXECUTING [13s]<========-----> 64% EXECUTING [14s]<========-----> 68% EXECUTING [14s]> :app:mergeDebugAndroidTestShaders<==========---> 80% EXECUTING [14s]> :app:mergeExtDexDebugAndroidTest> :app:mergeExtDexDebugAndroidTest > Resolve files of :app:debugRuntimeClasspat<==========---> 80% EXECUTING [15s]<==========---> 83% EXECUTING [15s]> :app:dexBuilderDebugAndroidTest> :app:dexBuilderDebugAndroidTest > Resolve files of :app:debugRuntimeClasspath<===========--> 89% EXECUTING [15s]> IDLE<===========--> 89% EXECUTING [16s]<===========--> 91% EXECUTING [16s]> :app:stripDebugDebugSymbols<===========--> 91% EXECUTING [17s]<===========--> 92% EXECUTING [18s]> IDLE
> Task :app:stripDebugDebugSymbols
Unable to strip the following libraries, packaging them as they are: libliveness-jni.so, libpl_droidsonroids_gif.so, libwrapper-lib.so.
<============-> 93% EXECUTING [18s]> IDLE> IDLE> :app:transformDebugClassesWithAsm> IDLE<============-> 93% EXECUTING [19s]<============-> 93% EXECUTING [20s]<============-> 93% EXECUTING [21s]<============-> 93% EXECUTING [22s]<============-> 94% EXECUTING [22s]> :app:dexBuilderDebug<============-> 94% EXECUTING [23s]<============-> 94% EXECUTING [24s]<============-> 94% EXECUTING [25s]<============-> 94% EXECUTING [26s]<============-> 94% EXECUTING [27s]<============-> 94% EXECUTING [28s]<============-> 94% EXECUTING [29s]<============-> 94% EXECUTING [30s]<============-> 95% EXECUTING [30s]> :app:mergeProjectDexDebug<============-> 95% EXECUTING [31s]<============-> 96% EXECUTING [31s]> :app:packageDebug<============-> 96% EXECUTING [32s]<============-> 96% EXECUTING [33s]<============-> 96% EXECUTING [34s]<============-> 96% EXECUTING [35s]<============-> 96% EXECUTING [36s]<============-> 98% EXECUTING [36s]> :app:connectedDebugAndroidTest > Resolve files of :app:androidTestUtil > orch> :app:connectedDebugAndroidTest > Resolve files of :app:androidTestUtil > test> IDLE> :app:connectedDebugAndroidTest<============-> 98% EXECUTING [37s]> :app:connectedDebugAndroidTest > Resolve dependencies of :app:_internal-unifi<============-> 98% EXECUTING [38s]<============-> 98% EXECUTING [39s]> :app:connectedDebugAndroidTest > Resolve files of :app:_internal-unified-test<============-> 98% EXECUTING [40s]> :app:connectedDebugAndroidTest> :app:connectedDebugAndroidTest > Resolve dependencies of :app:_internal-unifi> :app:connectedDebugAndroidTest > Resolve files of :app:_internal-unified-test> :app:connectedDebugAndroidTest<============-> 98% EXECUTING [41s]> :app:connectedDebugAndroidTest > Resolve dependencies of :app:_internal-unifi<============-> 98% EXECUTING [42s]> :app:connectedDebugAndroidTest > Resolve files of :app:_internal-unified-test> :app:connectedDebugAndroidTest> :app:connectedDebugAndroidTest > Resolve dependencies of :app:_internal-unifi> :app:connectedDebugAndroidTest > Resolve files of :app:_internal-unified-test<============-> 98% EXECUTING [43s]> :app:connectedDebugAndroidTest> :app:connectedDebugAndroidTest > Resolve dependencies of :app:_internal-unifi> :app:connectedDebugAndroidTest > Resolve files of :app:_internal-unified-test> :app:connectedDebugAndroidTest> :app:connectedDebugAndroidTest > Resolve dependencies of :app:_internal-unifi<============-> 98% EXECUTING [44s]> :app:connectedDebugAndroidTest > Resolve files of :app:_internal-unified-test> :app:connectedDebugAndroidTest > Resolve dependencies of :app:_internal-unifi<============-> 98% EXECUTING [45s]<============-> 98% EXECUTING [46s]<============-> 98% EXECUTING [47s]<============-> 98% EXECUTING [48s]> :app:connectedDebugAndroidTest > Resolve files of :app:_internal-unified-test> :app:connectedDebugAndroidTest > Resolve files of :app:_internal-unified-test> IDLE> :app:connectedDebugAndroidTest> :app:connectedDebugAndroidTest > Resolve dependencies of :app:_internal-unifi> :app:connectedDebugAndroidTest<============-> 98% EXECUTING [49s]<============-> 98% EXECUTING [50s]<============-> 98% EXECUTING [51s]<============-> 98% EXECUTING [52s]<============-> 98% EXECUTING [53s]<============-> 98% EXECUTING [54s]<============-> 98% EXECUTING [55s]<============-> 98% EXECUTING [56s]<============-> 98% EXECUTING [57s]<============-> 98% EXECUTING [58s]<============-> 98% EXECUTING [59s]<============-> 98% EXECUTING [1m]<============-> 98% EXECUTING [1m 1s]<============-> 98% EXECUTING [1m 2s]<============-> 98% EXECUTING [1m 3s]<============-> 98% EXECUTING [1m 4s]
> Task :app:connectedDebugAndroidTest
Unknown platform error occurred when running the UTP test suite. Please check logs for details.
Test results saved as file:/home/circleci/code/app/build/outputs/androidTest-results/connected/test-result.pb. Inspect these results in Android Studio by selecting Run > Import Tests From File from the menu bar and importing test-result.pb.
<============-> 98% EXECUTING [1m 4s]> IDLE> IDLE> :app:connectedDebugAndroidTest> IDLE<============-> 98% EXECUTING [1m 5s]
> Task :app:connectedDebugAndroidTest FAILED
<=============> 100% EXECUTING [1m 5s]> IDLE> IDLE> IDLE> IDLE
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///home/circleci/code/app/build/reports/androidTests/connected/index.html
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 6s
74 actionable tasks: 21 executed, 53 up-to-date
<-------------> 0% WAITING> IDLE> IDLE> IDLE> IDLEStarting test attempt 2
<-------------> 0% CONFIGURING [51ms]> root project > Resolve dependencies of :classpath<-------------> 0% CONFIGURING [151ms]> root project > Resolve files of :classpath<======-------> 50% CONFIGURING [251ms]> :app<======-------> 50% CONFIGURING [351ms]> :app > Resolve dependencies of :app:_agp_internal_javaPreCompileRelease_kaptC<======-------> 50% CONFIGURING [451ms]> :app > Resolve dependencies of :app:androidTestUtilCopy<======-------> 50% CONFIGURING [551ms]> :app > Resolve dependencies of :app:debugImplementationCopy<======-------> 50% CONFIGURING [651ms]> :app > Resolve dependencies of :app:debugImplementationDependenciesMetadataCo<======-------> 50% CONFIGURING [751ms]> :app > Resolve dependencies of :app:debugRuntimeClasspathCopy<======-------> 50% CONFIGURING [851ms]> :app<======-------> 50% CONFIGURING [951ms]> :app > Resolve dependencies of :app:implementationDependenciesMetadataCopy<======-------> 50% CONFIGURING [1s]> :app> :app > Resolve dependencies of :app:releaseRuntimeElementsCopy> :app
> Configure project :app
Disable pre dexing for module app
WARNING:DSL element 'dexOptions' is obsolete and should be removed.
It will be removed in version 8.0 of the Android Gradle plugin.
Using it has no effect, and the AndroidGradle plugin optimizes dexing automatically.
<=============> 100% CONFIGURING [1s]> IDLE<-------------> 4% EXECUTING [1s]> :app:dataBindingMergeDependencyArtifactsDebug > Resolve dependencies of :app:<=------------> 11% EXECUTING [1s]> :app:mergeDebugResources<===----------> 23% EXECUTING [1s]> :app:kaptGenerateStubsDebugKotlin > Resolve files of :app:debugCompileClasspa<===----------> 23% EXECUTING [2s]> :app:kaptGenerateStubsDebugKotlin<===----------> 24% EXECUTING [2s]> :app:kaptDebugKotlin<====---------> 32% EXECUTING [2s]> :app:dataBindingMergeDependencyArtifactsDebugAndroidTest > Resolve dependenci<====---------> 34% EXECUTING [2s]> :app:processDebugAndroidTestManifest > Resolve files of :app:debugRuntimeClas<======-------> 50% EXECUTING [2s]> IDLE<========-----> 62% EXECUTING [2s]> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath > Resolve> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath<========-----> 62% EXECUTING [3s]> :app:mergeExtDexDebug > Resolve files of :app:debugRuntimeClasspath > Resolve<========-----> 65% EXECUTING [3s]> :app:transformDebugClassesWithAsm > Resolve files of :app:debugCompileClasspa<==========---> 84% EXECUTING [3s]> :app:mergeDebugAndroidTestJavaResource<===========--> 89% EXECUTING [3s]> :app:mergeExtDexDebugAndroidTest > Resolve files of :app:debugRuntimeClasspat<============-> 98% EXECUTING [3s]> :app:connectedDebugAndroidTest > Resolve dependencies of :app:_internal-unifi> :app:connectedDebugAndroidTest<============-> 98% EXECUTING [4s]<============-> 98% EXECUTING [5s]<============-> 98% EXECUTING [6s]<============-> 98% EXECUTING [7s]<============-> 98% EXECUTING [8s]<============-> 98% EXECUTING [9s]<============-> 98% EXECUTING [10s]<============-> 98% EXECUTING [11s]
> Task :app:connectedDebugAndroidTest FAILED
Unknown platform error occurred when running the UTP test suite. Please check logs for details.
Test results saved as file:/home/circleci/code/app/build/outputs/androidTest-results/connected/test-result.pb. Inspect these results in Android Studio by selecting Run > Import Tests From File from the menu bar and importing test-result.pb.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///home/circleci/code/app/build/reports/androidTests/connected/index.html
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 12s
74 actionable tasks: 1 executed, 73 up-to-date
<-------------> 0% WAITING> IDLEMax tries reached (2)
Exited with code exit status 1