I try to make a CI test with Gradle Managed Device and Github action. I made several attempts, but I mostly run into
Execution failed for task ':app:nexusOneApi30Setup'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.ManagedDeviceSetupTask$ManagedDeviceSetupRunnable
> java.lang.IllegalStateException: Gradle was not able to complete device setup for: dev30_aosp_atd_x86_Nexus_One
This could be due to having insufficient resources to provision the number of
devices requested. Try running the test again and request fewer devices or
fewer shards.
As source I use https://github.com/android/testing-samples/tree/main/ui/espresso/ScreenshotSample in my fork which works local properly
Related
In gradle.properties I'm setting
org.gradle.unsafe.configuration-cache=true
This works without errors on my local machine. The output is:
0 problems were found storing the configuration cache.
When I set up a job on GitHub Actions, it only succeeds if I deactivate the configuration cache.
When it is activated I get this log:
3 problems were found storing the configuration cache, 1 of which seems unique.
- Task `:app:buildKotlinToolingMetadata` of type `org.jetbrains.kotlin.gradle.tooling.BuildKotlinToolingMetadataTask$FromKotlinExtension`: invocation of 'Task.project' at execution time is unsupported.
See https://docs.gradle.org/7.4.2/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
See the complete report at file:///home/runner/work/***/***/build/reports/configuration-cache/3lar58wlvtv9703t0m3olblg9/gwoz69d8l961obatzzelsv4d/configuration-cache-report.html
> Invocation of 'Task.project' by task ':app:buildKotlinToolingMetadata' at execution time is unsupported.
My primary interest is why this behaves differently.
I'm also wondering what the best workaround is.
(Can tasks be skipped from caching? Or how would you deactivate the configuration cache on the CI server?)
I haven't understood the cause yet.
My current workaround is to disable the configuration cache on CI builds adding the option --no-configuration-cache to all gradle commands e.g.
./gradlew test --no-configuration-cache
This overwrites the setting of gradle.properties.
Is there a way to run only the failed set of tests on Android using Gradle?
At the moment, I run my tests as follows.
./gradle connectedDebugAndroidTest
There are tests that occasionally fail due to environment issues which are difficult to control and what I would like to do is be able to only run those failed tests and merge the result with the previous test results.
So for example, if I have 100 tests and 90 succeed, I would like to re-run the failing 10 tests. If those 10 pass the second time around, I would like to merge those results with the original test run.
It looks like this has been discussed several times for Gradle but there doesn't seem to be a solution yet.
https://github.com/gradle/gradle/issues/4068
https://github.com/gradle/gradle/issues/4450
https://github.com/gradle/gradle/issues/1283
Thanks!
The reason they don't have a way to only rerun failed tests is because it screws up the way Gradle currently works. This happens because on the first run, Gradle knows 90 tests passed. If you update the code, and then rerun only the 10 failed tests (using this new option you want them to add), then Gradle would think that all the tests have passed. However, this isn't the case because the tests which previously passed might've broken from the update which fixed the failing tests.
Despite this, the problem has been solved. Gradle reruns failed tests first, and provides a --fail-fast flag for the test task. This effectively does what you want (i.e., only reruns failed tests).
If you want to automatically rerun failed tests as part of the same build in which they failed, and succeed the build if they succeed on retry, you can use the Test Retry Gradle plugin. This will rerun each failed test a certain number of times, with the option of failing the build if too many failures have occurred overall.
plugins {
id 'org.gradle.test-retry' version '1.2.0'
}
test {
retry {
maxRetries = 3
maxFailures = 20 // Optional attribute
}
}
I am trying to build my android project on Jenkins 2.0 server on Ubuntu machine.
I am running the following commands for that purpose:-
./gradlew clean (this is working fine)
./gradlew build (this is failing random number of test cases)
However I also install Jenkins 2.0 on my Windows 7 machine and run the same commands as above, and it was passing all test cases every time. I am not understanding what is wrong with that.
I did lot of debugging but could not find any solution, please help me to get rid out of this thing...!
This is my 34th build log on Jenkins
testPreCondition FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
handleBackButtonPressing FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
48 tests completed, 2 failed
:app:testDebugUnitTest FAILED
This is my 35th build log on Jenkins without making any code changes
> handleBackButtonPressing FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
> testPreCondition FAILED
java.lang.NullPointerException at ConfigurationFragmentTest.java:36
> testPreconditions FAILED
java.lang.NullPointerException at UpdateTabFragmentTest.java:30
> testPreconditions FAILED
java.lang.NullPointerException at ServiceTabFragmentTest.java:29
> testPreConditionIsNotNull FAILED
java.lang.NullPointerException at HomeActivityTest.java:63
48 tests completed, 5 failed
:app:testDebugUnitTest FAILED
You should check the Jenkins console output for something like
"WARNING: No manifest file found " in the console output.
Those NPEs are typical for missing resources.
The most common source for failing robolectric builds on different environmnets is probably robolectric not beeing able to load any resources.
Since robolectric needs to know where your Android Manifest is, you may have to provide a extra robolectric.properties for the build
http://robolectric.org/configuring/
I've been successfully running Robolectric unit tests under the debugger in Android Studio since version 0.6.1
Now I am unable to and get the following error
ERROR: transport error 202: connect failed: Connection refused
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../../../src/share/back/debugInit.c:750]
Could not write standard input into: Gradle Test Executor 1.
java.io.IOException: Broken pipe
I have always set the use in-process build flag unchecked in the compile settings and although I am currently using AS 0.8-14, I have gone back and tried 0.8-11, 0.8-9 and 0.6-1 and none of them work now. I'm using android build tools version 19.1.0 (and have been for some time and it does work with them).
Could it be some local security setting under Mac OS X? Any assistance would be gratefully received.
** Update **
I have discovered that the issue is caused by running an additional JavaExec task before running the unit test tasks. It seems that gradle is running the JVM for the first task and passing debug arguments to it e.g. -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=49807 The task completes and the JVM exits. Gradle then runs the actual unit test and expects the new JVM to listen on the same port for the debugger to connect - which it doesn't and so the connection failure arises.
How can I either prevent the prior task (an ormlite database compile task) from running under the debugger or force gradle to recognise that the unit test task will run using a new JVM and so change the jvmArgs for the unit test to reflect the new debug port?
I fixed this by changing the database compilation task to be an Exec task rather than a JavaExec task. The exec task was defined as follows and so executed the database compilation as an external java process, not a gradle invoked one. This prevented the debug JVM being 'consumed' by the database compilation task.
task (taskName type: Exec) {
def mainClass = "com.some.class"
def classPath = "${buildDir}/intermediates/classes/${flavorName}/${buildType.name}" + ":" + configurations.databaseCompile.asPath
commandLine "java", "-cp", classPath, mainClass, configDirName
}
whenever I add an Android project to a git repository using the eclipse plugin EGit I get this Error message
Failed to initialize Git team provider.
when visualising the error log I get this :
Failed to initialize Git team provider.
Problems encountered while moving resources.
Could not move '/SearchInContatsWithLoader'.
Could not move: D:\AndrComp\SearchInContatsWithLoader.
Problems encountered while deleting files.
Could not delete: D:\AndrComp\SearchInContatsWithLoader\libs\android-support-v4.jar.
Could not delete: D:\AndrComp\SearchInContatsWithLoader\libs.
Could not delete: D:\AndrComp\SearchInContatsWithLoader.
Check if you don't have a windows process blocking those file (keeping an handle on them), which would prevent another process (like EGit) to move them.
To solve the issue, try to close as many processes as you can (or, even better, reboot and launch just Eclipse), and try again your operation.