EDIT: Below is the original post. It was the initial issue I had ran into, but repeating my steps over and over I am getting different results. The first time I tried to run my shards after posting this, I got:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ProgressiveApp:packageInternalStaging'.
> invalid distance too far back
The next time:
> invalid code lengths set
And the next:
> Unexpected end of ZLIB input stream
All three appear to be zip/compression related issues. Perhaps this is my primary issue.
Original post below:
I'm using AndroidX Espresso 3.1.0 along with ANDROIDX_TEST_ORCHESTRATOR. The only issue I have is that when I run shards (to speed up test runs), it sometimes decides to fail for no good reason.
For example, I open three terminals and three emulators. I run one of these in each terminal to kick off three separate shards:
ANDROID_SERIAL=emulator-5554 ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.numShards=3 -Pandroid.testInstrumentationRunnerArguments.shardIndex=0
ANDROID_SERIAL=emulator-5556 ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.numShards=3 -Pandroid.testInstrumentationRunnerArguments.shardIndex=1
ANDROID_SERIAL=emulator-5558 ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.numShards=3 -Pandroid.testInstrumentationRunnerArguments.shardIndex=2
This then runs a third of my tests on each emulator. So good so far. After a long time, they're all done and I have a nice HTML report telling me zero tests failed. I haven't touched my code, I haven't touched the emulators. I go to touch each of the terminals. In each I hit the up arrow to grab the last command ran in that terminal, and then enter to rerun exactly what I just ran. Two of the emulators are fine and run through all their tests. The third does not, and gives me this error message below:
> Task :<snip>:connectedInternalStagingAndroidTest FAILED
[no message defined]
java.lang.RuntimeException: com.android.builder.testing.api.DeviceException:
com.android.ddmlib.InstallException: INSTALL_FAILED_INVALID_APK
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: INSTALL_FAILED_INVALID_APK
at com.android.builder.testing.ConnectedDevice.installPackage(ConnectedDevice.java:132)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:147)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:59)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
... 4 more
Caused by: com.android.ddmlib.InstallException: INSTALL_FAILED_INVALID_APK
at com.android.ddmlib.Device.installRemotePackage(Device.java:1031)
at com.android.ddmlib.Device.installPackage(Device.java:902)
at com.android.ddmlib.Device.installPackage(Device.java:880)
at com.android.ddmlib.Device.installPackage(Device.java:869)
at com.android.builder.testing.ConnectedDevice.installPackage(ConnectedDevice.java:126)
... 7 more
Why? How? It doesn't make any sense. I hit up and enter again and then it happily runs through all the tests without issue.
My problem is that this random failure happens enough I can't set up my machines to use sharding, and therefore cannot speed up the test running process for my team.
Related
I tried to generate code report using detekt and when execute the below command in terminal
gradle detekt
it showing build failed with below message.
* What went wrong:
Execution failed for task ':app:detekt'.
> Build failed with 395 weighted issues.
As others have said in the comments, this means you have 395 issues in your code (kind of like lint warnings).
Detekt has a maxissues: property that determines whether or not to fail the build if your issues surpass the allowed number of maxissues. What I did was search the whole project for maxissues, which will take you to your detekt-config.yml or default-detekt-config.yml. There, you can change your maxissues to whatever you want.
In our old code base, we had 900 some issues, so I changed mine from maxissues:0 to masissues:1000. As we clean up the code, I hope to bring that number down.
"Cause: invalid code lengths set" error. The run tasks ended at App:packageDebug. From the long list of things, three under compiler are more informative I guess:
org.gradle.tooling.BuildException: invalid code lengths set
java.util.zip.ZipException: invalid code lengths set
java.lang.IllegalStateException: Still waiting to inspect output APK's res/raw/shape_predictor_68_face_landmarks.dat
On the right side there was: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:packageDebug'.
I searched all over the places and tried everything I could find, but it did not work. Also, I cleaned the cache and restarted, I tried different emulator and devices. I also tried different project settings and structure settings. I also noticed that a very similar post was not answered: build failed because of "org.gradle.tooling.BuildException: invalid code lengths set"
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 am attempting to install the sample app here: https://github.com/brentvatne/react-native-scrollable-tab-view
After install, I attempt to run, but the error appears:
:react-native-vector-icons:processReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-vector-icons:processReleaseResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.E
xecException: Process 'command 'C:\Users\KJA\AppData\Local\Android\sdk\build-too
ls\23.0.1\aapt.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 23.638 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
How can this be alleviated?
ref: https://github.com/oblador/react-native-vector-icons/issues/102
I spent a whole lot of time trying to figure out this error, and (at least for me) it turns out to be something really stupid, and largely unrelated to the react-native-vector-icon library.
After many hours of A-B-A testing, I have come to the conclusion that this library has some very long path names in it.
This really adversely affects Windows users.
If I have my project located at: C:\Users\MyName789\Dropbox\123 Software Development -- React Native\IconExplorer we get a total fail.
If I move the project to: C:\IconExplorer everything works well.
Recommendation for Windows users: There are many files affected while running react-native run-android. Long file name addresses will result in numerous errors, including Execution failed for task ':react-native-vector-icons:processReleaseResources' With that said, keep your file path names as short as possible!
On Windows one could fire up regedit, then search for
LongPathsEnabled
and set it to 1.
Do a reboot afterwards and if the problem lies only within long path names, it should be gone.