Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradle clean behavior #166

Open
bonitao opened this issue Jun 13, 2022 · 4 comments
Open

gradle clean behavior #166

bonitao opened this issue Jun 13, 2022 · 4 comments

Comments

@bonitao
Copy link

bonitao commented Jun 13, 2022

When I run gradle clean, I get

java.io.IOException: Unable to delete directory 'C:\Users\davir\code\trash\build'
    Failed to delete some children. This might happen because a process has files open or has its working directory set in the target directory.

In some ways, this is expected. For example, when I have Android Studio open. But even when it is not the case there is often some process with a handle on the directory. I wonder if this is a know problem?

An alternative here would be to keep the sdk outside the build tree, maybe in tmp with hash addressing. That way even with the sdk being used gradle clean would succeed.

@quittle
Copy link
Owner

quittle commented Jun 14, 2022

Hey, thanks for reaching out. I've found that Android Studio or the emulator can leave background processes running that you may not expect, which could be causing this issue.

In addition, I believe that this plugin creates additional clean tasks to delete the SDK as part of cleanup even if you customized the location it installs to in your build config. You can programmatically disable that task if you like in your build.gradle if you prefer.

I'm on vacation at the moment though and may be slow to further respond this week.

@quittle
Copy link
Owner

quittle commented Jun 23, 2022

Was that sufficient to resolve your issue?

@quittle
Copy link
Owner

quittle commented Jul 16, 2022

@bonitao Bump

@bonitao
Copy link
Author

bonitao commented Aug 14, 2022

Hi @quittle ,

Unfortunately the issue persists. I believe the source of the problem is more fundamental, since the sdk is a dependency of the build process, and the gradle-setup-android-sdk sees it as a byproduct of the build process. As something cannot be a dependency and a byproduct at the same time without incurring in a loop, problems arise in some edge cases.

The only fix I can see is the one I proposed. Treat the sdk as any other dependency, by installing it with version information (which will even allow transitions when you upgrade it) under the dependency cache: https://docs.gradle.org/current/userguide/dependency_management.html#sec:dependency_cache. Then you can point local.properties there, and the build directory is no longer an input for the build process.

I understand this is a big change, but wanted to leave the suggestion here anyway in case you find it useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants