Status Update
Comments
ri...@google.com <ri...@google.com> #2
enableUnitTestCoverage = false
enableAndroidTestCoverage false
Thinks started to work again.
But for what it is worth - the error message could have been more helpful.
cm...@google.com <cm...@google.com> #3
Well the error message is that it tried to configure jacoco task and failed, so it works for you because you disabled the feature.
So the error message is indicative of a bigger problem. Oviously, 8.2 is pretty old for us, not sure you are interested in trying 8.8.
The easiest would be to have a project reproducing the issue, if that's possible, we'll look into it.
ro...@glovoapp.com <ro...@glovoapp.com> #4
Unfortunately we haven't had the resources to keep things up to date for a long time - and now every possible problem is just piling up...
I'll get back once we manage to upgrade to 8.8...
hu...@google.com <hu...@google.com> #5
Just a quick question to isolate the root cause: Are you building android.splits.density.enable = true
in build.gradle
)?
eb...@netflix.com <eb...@netflix.com> #6
Not with APK spli, we're building multiple APK in this CI job because we have multiple app in the project. We're buiding each of them using assembleRelease
hu...@google.com <hu...@google.com> #7
Thanks, so this is not related to the ShrinkResourcesNewShrinkerTask
.
The root exception is:
Caused by: java.io.IOException: Request to write '65536' bytes exceeds size in header of '4046477' bytes for entry 'tree-params.logFile'
at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.write(TarArchiveOutputStream.java:666)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1488)
at org.gradle.caching.internal.packaging.impl.TarBuildCacheEntryPacker$PackingVisitor.storeFileEntry(TarBuildCacheEntryPacker.java:444)
... 111 more
The tree-params.logFile
mentioned in the above message is located at <module>/build/outputs/mapping/release/resources.txt
.
Could you go to that file in your :modules:ui:my-d:demo:
module and let me know the size of that file to see if it matches the message above?
hu...@google.com <hu...@google.com> #8
To help us debug, could you add the following script to the build.gradle.kts
file of the failed module:
val shrinkResourcesLogFiles = mutableMapOf<ShrinkResourcesNewShrinkerTask, File>()
val debugFile = File("debug_391259240.txt")
debugFile.writeText("")
fun debug(taskName: String, logFile: File, messagePrefix: String) {
val message = "$messagePrefix [${System.currentTimeMillis()}] Task `$taskName`'s logFile = $logFile (${logFile.length()} bytes)"
println(message)
debugFile.appendText(message + "\n")
}
tasks.withType(ShrinkResourcesNewShrinkerTask::class) {
doFirst {
val logFile = (this as ShrinkResourcesNewShrinkerTask).params.logFile.get().asFile
shrinkResourcesLogFiles[this] = logFile
debug(name, logFile, messagePrefix = "[Start of task]")
}
doLast {
val logFile = (this as ShrinkResourcesNewShrinkerTask).params.logFile.get().asFile
debug(name, logFile, messagePrefix = "[End of task] ")
}
}
gradle.buildFinished {
shrinkResourcesLogFiles.forEach { (task, logFile) ->
debug(task.name, logFile, messagePrefix = "[End of build] ")
}
}
and share with us the contents of debug_391259240.txt
(removing any confidential parts): one for when the build succeeds and one for when the build fails?
hu...@google.com <hu...@google.com> #9
Adding some more context:
- The only difference between AGP 8.7 and AGP 8.8 relating to the
shrinkReleaseRes
task is where we set thethis commit logFile
parameter (resources.txt
next to<module>/build/outputs/mapping/release/mapping.txt
) as an@OutputFile
of this task. - Since
is now a task's output, Gradle starts including it in the build cache, and we run into this error.logFile
- Reverting the above commit is not ideal because that change is not a bug, it just exposes an existing bug.
To help us debug this issue: Please try
tasks.withType(ShrinkResourcesNewShrinkerTask::class) {
outputs.doNotCacheIf("Workaround for bug 391259240") { true }
}
This script will disable caching for the shrinkReleaseRes
task. After that:
- If the build succeeds consistently, you can use it as a workaround for this bug.
- If the build still sometimes fails, it will now fail with a different stack trace. Please send us that stack trace.
hu...@google.com <hu...@google.com> #10
One more question: Are you building both the APK (assembleRelease
) and the bundle (bundleRelease
) in the same build? (Both of them write to the same resources.txt
file.)
eb...@netflix.com <eb...@netflix.com> #11
Yes, basically we're building bundles for our main app and APKs for a bunch of demo apps. I'll try the debugging code you added a bit later...
hu...@google.com <hu...@google.com> #12
To clarify, there are 2 cases:
- If you build the APK for
app1
and the bundle forapp2
, AGP will write to differentresources.txt
files inapp1
andapp2
. This is expected. - If you build both the APK and the bundle for
app1
, then two AGP tasks will write to the sameresources.txt
file (app1/build/outputs/mapping/release/resources.txt
). => This could potentially explain this bug.
Looks like your case is #1, so we'll still need to track down the root cause.
ro...@glovoapp.com <ro...@glovoapp.com> #13
Hi,
I've added the logging script recommended in #8 and executed some runs in my CI to reproduce the issue. Find attached the logs for a successful and failed builds executed with the latest AGP 8.8.2. These confirm the error message about an inconsistent size of the resources.txt file.
My use case is generating both the main apk artifact and the android-test artifact to execute instrumented tests (so something like ./gradlew assemble assembleAndroidTest
with shrinkResources enabled). This consistently fails in 5% of our builds.
For now we applied the workaround from #9 (which works fine so far) to unblock the AGP bump, but this is not a fast task so disabling cache is not a good long term solution for our developers experience. Please let us know if you need any further information to resolve this issue.
Thanks!
hu...@google.com <hu...@google.com> #14
Both of your logs print:
[Start of task] [1741189744738] Task `shrinkNoneStageDebugRes`'s logFile = /myproject/app/build/outputs/mapping/noneStageDebug/resources.txt (0 bytes)
[End of task] [1741189771317] Task `shrinkNoneStageDebugRes`'s logFile = /myproject/app/build/outputs/mapping/noneStageDebug/resources.txt (6533034 bytes)
[End of build] [1741189784304] Task `shrinkNoneStageDebugRes`'s logFile = /myproject/app/build/outputs/mapping/noneStageDebug/resources.txt (7047237 bytes)
That means something is writing to the file after the task is finished.
Could you use the following build script to find out which task is doing that?
val resourcesTxtFile = File("app/build/outputs/mapping/release/resources.txt")
val debugFile = File("debug_391259240.txt")
debugFile.writeText("")
fun log(buildEvent: String) {
val message = "[${LocalDateTime.now()}] $buildEvent resourcesTxtFile's size = ${resourcesTxtFile.length()} bytes"
println(message)
debugFile.appendText(message + "\n")
}
tasks.configureEach {
doFirst {
log("[Start of task '$name']")
}
doLast {
log("[End of task '$name'] ")
}
}
gradle.buildFinished {
log("[End of build] ")
}
If possible, can you also attach or compare the contents of the file when it has 6533034 bytes vs. when it has 7047237 bytes and let us know the differences?
Description
After we updated to AGP 8.8.0 we got this error intermittently (but enough for us to revert back to previous AGP). It's worth to mention we're having an issue with R8 and are using the version recommended on this issue : https://issuetracker.google.com/issues/389508413
I wasn't able to reproduce locally unfortunately.
Here the full stack trace: