We have a custom android gradle plugin that does compile time weaving in order to instrument networking access.
We weave the AARs found in the app’s classpath (in
build/intermediate/exploded-aar) and JARs that are found to be dependencies of the app (most are in
This works great in OSX however in Windows we are unable to overwrite the original jars with our weaved jars due to FileSystemException sharing violations (“The process cannot access the file because it is being used by another process”).
Turning off Windows Defender or search indexer doesn’t help. The SysInternals Procmon tool shows that the files are already open by the same process/thread as the one trying to overwrite the orignal jars which is the gradle java.exe process.
We are doing the AAR weaving in a Javacompile.doFirst and the dependency JAR weaving in a Javacompile.doLast task.
I tried turning off daemon by setting
org.gradle.daemon=false in gradle.properties with no change.
Has anyone encountered this issue under Windows? The files seem to be open by gradle, is there a way to close them before weaving?
Should we be doing it in another task that doesn’t already have the files open?