Status Update
Comments
ks...@google.com <ks...@google.com>
je...@google.com <je...@google.com>
ga...@google.com <ga...@google.com> #2
cp...@gmail.com <cp...@gmail.com> #3
Hence closing this issue.
ga...@google.com <ga...@google.com> #4
Can you please add the following to your Module/build.gradle
file and run ./gradlew :Module:minifyNetCleanReleaseWithR8 > output.txt
, and upload output.txt
?
gradle.taskGraph.whenReady {
this.allTasks.forEach { t ->
println("Task name = " + t.name + ": ")
println(t.outputs.files.joinToString())
println(" ---- done with outputs for " + t.name)
}
}
Also, can you please share full stacktrace (./gradlew :Module:minifyNetCleanReleaseWithR8 --stacktrace
)?
From logs in #3, I can see:
:Module:mergeNetCleanReleaseJavaResource SKIPPED
:NeoTheme:bundleLibRuntimeToJarNetCleanRelease SKIPPED
:BaseModule:bundleLibRuntimeToJarNetCleanRelease SKIPPED
:Module:minifyNetCleanReleaseWithR8 SKIPPED
i.e. mergeNetCleanReleaseJavaResource
runs before R8, so dependency info seems fine.
However, from logs:
ERROR: /home/andrew/StudioProjects/Projects/Module/build/intermediates/merged_java_res/netCleanRelease/base.jar: R8: com.android.tools.r8.ResourceException: com.android.tools.r8.internal.Sb: I/O exception while reading '/home/andrew/StudioProjects/MoPoClient_Android2/MoPoClub/build/intermediates/merged_java_res/netCleanRelease/base.jar': /home/andrew/StudioProjects/Project/Module/build/intermediates/merged_java_res/netCleanRelease/base.jar
which seems odd. I cannot find any other reference to MoPoClient_Android2
in the logs. Do you have some additional info on this?
cp...@gmail.com <cp...@gmail.com> #5
I succeeded to replicate error for template project: netCleanDebug verssion works, but netCleanRelease fails with base.jar not found
ga...@google.com <ga...@google.com> #6
Thanks for sharing the repro. The issue is in the build script that triggers eager task creation, which breaks AGP task configuration. Please use:
tasks.configureEach {
if(name.startsWith("connectedNet")) {
enabled = false
}
}
instead of tasks.whenTaskAdded
(see
Sidenote: I'd advise against disabling tasks in this way. If you'd like to disable instrumented tests, see
eg...@gmail.com <eg...@gmail.com> #7
Saved my day, faced with following issue after migration to AGP 8.1.0.
Can confirm tasks.configureEach {}
fix the problem
ma...@gmail.com <ma...@gmail.com> #8
This fixed my compilation crash as well - however, configureEach
does not work the same. I want to attach the lintDevDebug
task to my sonar
task, and was doing it like so:
project.tasks.whenTaskAdded {
if (name == "lintDevDebug") {
project.rootProjects.tasks.findByName("sonar")?.let { sonarTask ->
sonarTask.dependsOn(this)
}
}
}
Replacing whenTaskAdded with configureTask, I never see a task with the name of lintDevDebug
- I never see any of the tasks added by the android plugin.
If we can't use whenTaskAdded
, how are we supposed to hook into the AGP provided tasks now?
ma...@reverb.com <ma...@reverb.com> #9
It might have been nice if this breaking change with whenTaskAdded
was mentioned in the release notes when 8.1 became stable. The lint warning/intention action is helpful, but not severe enough since it is definitely going to break minified builds.
ga...@google.com <ga...@google.com> #10
Re #8: configureEach
is triggered differently from whenTaskAdded
, only when there is a direct request to execute it or another task depends on it. In general, we discourage setting task dependencies explicitly; instead these should be modeled through AGP APIs (
Coming back to your snippet, this should work:
project.tasks.configureEach {
if (name == "sonar") {
it.dependsOn("lintDevDebug")
}
}
Re #9: This Gradle API is pretty much incompatible with lazy task configuration (
sh...@gmail.com <sh...@gmail.com> #11
file or directory '/app/build/intermediates/generated_proguard_file/devRelease/proguard.txt', not found
ERROR: /app/build/intermediates/merged_java_res/devRelease/base.jar: R8: com.android.tools.r8.ResourceException: com.android.tools.r8.errors.CompilationError: I/O exception while reading '/app/build/intermediates/merged_java_res/devRelease/base.jar': /app/build/intermediates/merged_java_res/devRelease/base.jar
0 problems were found storing the configuration cache.
See the complete report at file:///build/reports/configuration-cache/9aynqp5b679sxmw1g1jpwpau5/cd0jeiziagypy3i5zvkk97s8w/configuration-cache-report.html
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:minifyDevReleaseWithR8'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.R8Task$R8Runnable
> Compilation failed to complete, origin: /app/build/intermediates/merged_java_res/devRelease/base.jar
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at
BUILD FAILED in 2s
333 actionable tasks: 20 executed, 1 from cache, 312 up-to-date
Watched directory hierarchies: [....]
Configuration cache entry stored.
When I try to execute this command ./gradlew clean :app:mergeDevReleaseJavaResource --info got below result, not sure why that directory is removed but base.jar is available in app/build/intermediates/merge_java_res/
Output property 'outputFile' file
/app/build/intermediates/merged_java_res/devRelease/base.jar has been removed.
The input changes require a full rebuild for incremental task ':app:mergeDevReleaseJavaResource'.
BUILD SUCCESSFUL in 2s
292 actionable tasks: 89 executed, 203 from cache
Watched directory hierarchies: [...]
Configuration cache entry reused.
Something is happening while executing the minify command which is removing the base.jar file.
Please try to give me solution to fix this issue. Thanks
ga...@google.com <ga...@google.com> #12
See previous comments #6 and #10 on how to fix this issues, thanks.
sh...@gmail.com <sh...@gmail.com> #13
EDITED: Thanks guys, finally it worked :)
ma...@bit-worker.com <ma...@bit-worker.com> #14
fr...@gmail.com <fr...@gmail.com> #15
fr...@gmail.com <fr...@gmail.com> #16
It seems like the JAR is there at the end of the previous task. R8 checks that the jar is there (see screenshot)
Then the logs show
2023-08-26T09:40:31.870-0400 [DEBUG] [org.gradle.internal.vfs.impl.AbstractVirtualFileSystem] Invalidating VFS paths: [/build/projects/app/tfa/outputs/mapping/defaultRelease/mapping.txt, /build/projects/app/tfa/outputs/mapping/defaultRelease/missing_rules.txt, /build/projects/app/tfa/intermediates/merged_art_profile/defaultRelease/baseline-prof.txt, /build/projects/app/tfa/intermediates/dex/defaultRelease/minifyDefaultReleaseWithR8, /build/projects/app/tfa/intermediates/merged_java_res/defaultRelease/base.jar, /build/projects/app/tfa/outputs/mapping/defaultRelease/configuration.txt, /build/projects/app/tfa/outputs/mapping/defaultRelease/seeds.txt, /build/projects/app/tfa/outputs/mapping/defaultRelease/usage.txt]
Then the minify task fails. It seems like no other task is running at the same time and I can only assume that r8 is removing the JAR itself? This seems like a bug?
ca...@gmail.com <ca...@gmail.com> #17
There are no gradle tasks using `whenTaskAdded` in our build stack.
Any other suggestions?
ch...@q42.nl <ch...@q42.nl> #18
Also running into the issue here, not using whenTaskAdded
.
I managed to fix it since I found the following config in our module to edit test config:
tasks.matching { it instanceof Test }.all { // Show more test execution information
testLogging.events = ["failed", "passed", "skipped"]
testLogging.exceptionFormat "full"
}
Instead of the .all
, we need to use .configureEach
here!
jo...@gmail.com <jo...@gmail.com> #20
ja...@gmail.com <ja...@gmail.com> #21
my...@gmail.com <my...@gmail.com> #22
Will there be any fix for this? Because soon it will be mandatory to support API 34, and this is impossible because of a bug in the build.
no...@gmail.com <no...@gmail.com> #23
ge...@gmail.com <ge...@gmail.com> #24
FYI, in our case the culprit was a 3rd-party plugin gradle assembleRelease
was succeeding.
Once we upgraded the plugin to an AGP 8+-supporting version (1.4.0), the problem went away.
al...@gmail.com <al...@gmail.com> #25
ra...@gmail.com <ra...@gmail.com> #26
da...@orgmob.com <da...@orgmob.com> #27
I ran into this upgrading from gradle 8.0.2 to 8.2.2, to match upgrading from Android Studio Flamingo to Hedgehog.
I made all the changes directed in the
Using the approach listed in build.gradle
file:
ant.importBuild("${<location-of-ant-project>}/build.xml") { antTargetName ->
'<prefix-I-used>-' + antTargetName
}
For me this was not currently in use, so I've just commented it out, but it seems to me that perhaps it's a gradle (packaging?) bug with the implementation of AntBuilder org.gradle.api.Project.getAnt()
that's shipping with Android Studio?
gu...@gmail.com <gu...@gmail.com> #28
br...@multibrain.net <br...@multibrain.net> #29
ha...@gmail.com <ha...@gmail.com> #30
The error that I'm getting is
Task :app:minifyKioskDebugWithR8 FAILED AGPBI: {"kind":"error","text":"com.android.tools.r8.ResourceException:
Reference issue.
Please anyone help me on this!
je...@google.com <je...@google.com>
hm...@google.com <hm...@google.com> #31
#29 and #30 if you are not using any of the "eager apis" outlined here (
Please include a list of third party plugins you are depending on too.
an...@google.com <an...@google.com> #32
In the future, if you encounter this or any other issue, please read
Thank you!
Description
Gradle fails to assemble release build, debug build is assembled fine & it works on devices.
But release build is not assembled because r8 requires /build/intermediates/merged_java_res/release/base.jar
which is not present at the moment of the execution of minify task
Task :Module:mergeNetCleanReleaseGeneratedProguardFiles UP-TO-DATE
> Task :Module:processNetCleanReleaseJavaRes
> Task :Module:mergeNetCleanReleaseJavaResource
> Task :Module:minifyNetCleanReleaseWithR8 FAILED
AGPBI: {"kind":"error","text":"com.android.tools.r8.ResourceException:
I have tried manually launch task mergeNetCleanReleaseJavaResource and base.jar is generated which is the same as in the debug buildVariant and contains nothing special just some metadata from libraries. It is attached below.
Build with debug or stacktrace gives no additional information because stack trace is for r8 which can't find base.jar which is deleted by some previous tasks.
Build: AI-223.8836.35.2231.9848316, 202303300030
AI-223.8836.35.2231.9848316, JRE 17.0.6+0-17.0.6b653.34-9746777x64 JetBrains s.r.o., OS Linux(amd64) v5.15.0-69-generic, screens 3440.0x1440.0
AS: Giraffe | 2022.3.1 Canary 11
Kotlin plugin: 223-1.8.0-release-345-AS8836.35.2231.9848316
Android Gradle Plugin: 8.1.0-alpha11
Gradle: 8.0
Gradle JDK: JetBrains Runtime version 17.0.6
NDK: from local.properties: (not specified), latest from SDK: (not found)
CMake: from local.properties: (not specified), latest from SDK: (not found), from PATH: (not found)
```