Remove project totaly from .gradle

Hi,

I am using Android Studio.
It is possible to remove in the .gradle directory everything concerning a project.
Or do i need to delete .gradle and rebuild all the projects i got.

thanks

So i decided to remove everything from my computer from android studio and gradle.

And i think it is a bad idéa to not organized everything by project rather to put everything on the same .gradle directorie with hash code for everything we do not know what belong to who, exept for the gradle wrapper of course.

i had to delete more tha 25 GIga from .gradle in 8 years. 99% are not even used anymore since long time.

Actually, it would be bad if it would be separate per project and waste a great amount of space by having all kinds of things multiple times and maybe even multiple times for the same project if you go by path which you would have to do as different projects could have the same name but be different projects.

The things in GRADLE_USER_HOME are the things that are not project specific, but can work cross-project like task output cache that can be reused in different projects find if the inputs are the same, or cached dependencies that are the same for all projects and so on.

Project specific things would typically be in .gradle in the root project.

To redo things you could also run with --rerun-tasks then tasks are rerun properly.

Unused things in GRADLE_USER_HOME should usually be regularly cleaned up unless you use ancient Gradle version.
Except for some things like daemon log files that do not have a cleanup yet and actually can make quite some Gigs.

If you want separate GRADLE_USER_HOME per project, you could also simply use a dedicated GRADLE_USER_HOME per project. But figuring out what belongs to a specific project in a common GRADLE_USER_HOME is not possible as far as I know.

I am old scool, not very used with all the gradle staff.

what do you mean by path “if you go by path which you would have to do as different projects could have the same name but be different projects”.
Id do not anderstand path-samename(of what)-different project(what will deffiriate them)

where to put --rerun-tasks

where to put the GRADLE_USER_HOME and what does it means.

I agree for the gradle wrapper and the depedencies. No need to donwload it for each project. But the problem is running 2 android studion version using the same project for testing New NDK,valid android version and so on.

I gave you an example. i was running 2 copie of the same project with 2 name TOTO and TOTO1 in two different directories and using 2 android studio, A and B.
So i used both project with both AS(android studio).
I supress TOTO from AS B. Make some test with the NDK in AS A.
Than close AS A. Then i reopen TOTO project in AS B. And i gave me the name of TOTO1 but the code of TOTO. Strange gradle mix up.

So i had to suppres everything from gradle and AS.

I my case i use external library that i need to build and rebuild for every version of the NDK, it is C++ code. After One week of testing trying to test new phonne with higher android version i need the AS how will have this version in the NDK, AS B.

So after running both project on different IDE version with diffrent NDK. I needed to change NDK version to be able to rebuild the project. And i took information From the wrong project. So it is why i said that information about project, version and so on became instable.

If i had a gradle directory per project name, not installation name. I would need one gradle for each IDE version. If i got a gradle how save java build, c++ build with different gradle version, because different IDE. It become the mess it could not even rebuild when i changed code in C++. rebuild with wrong NDK, exct.

if i had by project organized like that.

project toto - IDE version - JRE version - Gradle Version - gradle build - android version -NDK version - file version.

I could select to dellete either IDE version, gradle exct… and make some clean up esely.

Now i need to clean project by NDK version and even this do not work properly.

Another example when your are testing a project. somme time you need to try different gradle and build if you change IDE version. So at the end you got your project with gradle for one IDE and Gradle for another and some time you need to donwload new depedencie and even new JRE.

If youy use the same project or a copy. At the end it is the mess. And Hash code name is not very nice to find out what belong to how.

what do you mean by path “if you go by path which you would have to do as different projects could have the same name but be different projects”.

I meant if you would want to have separation per project in GRADLE_USER_HOME, then you would have to do it per /path/to/the/project as in /path/to/another/project there could be a project with the same group and name. And even then it would be unreliable as you could have different projects at the same path over time. Besides that you would then have things multiple time on disk unnecessarily and would also loose much of the functionality of things like task output cache if you use multiple worktrees for the same project or have tasks in different projects that would be able to reuse the cache.

where to put --rerun-tasks

When you invoke Gradle, like ./gradlew --rerun-tasks build. Of course this will do what it was told and rerun all tasks that are in the task graph, disabling one of the greatest strengths of Gradle, that is avoiding unnecessary work.

where to put the GRADLE_USER_HOME and what does it means.

GRADLE_USER_HOME is an environment variable you can set or alternatively you can also use the -g or --gradle-user-home commandline option to set it. This by default is ~/.gradle/ and the directory you talk about. So if you want separate .gradle per project, you need to manually configure that.

But the problem is running 2 android studion version using the same project for testing New NDK,valid android version and so on.

Same there, there is no reason to have these on disk multiple times if different projects could use it. Android is a bit special always of course, so :man_shrugging:. If the Android Gradle Plugin is putting stuff into GRADLE_USER_HOME and does not do a periodic cleanup of unused stuff like the Gradle built-in things do for many parts, then this should be a feature request to the Android Gradle Plugin to introduce such a cleanup functionality.

Then i reopen TOTO project in AS B. And i gave me the name of TOTO1 but the code of TOTO. Strange gradle mix up.

Hard to say what happened from this condensed and abstract description, but sounds like a bug somewhere. Actually it is unlikely that it is a bug in Gradle, but probably either in the Android Gradle Plugin or Android Studio. If you are able to reproduce the error, you should knit an MCVE and report the issue to the assumed culprit(s).

I would need one gradle for each IDE version.

So not even per project. That makes it even less a Gradle issue. :smiley:
Maybe if you have one worktree per IDE and then configure via gradle.properties different Gradle User Homes that would help for your situation. :man_shrugging: But still it sounds like a bug that should be fixed somewhere.

And Hash code name is not very nice to find out what belong to how.

That’s the point. What is hashed does not belong to and Gradle version or IDE version it whatever. It belongs to what is hashed. If the Gradle version is relevant, then it will be part of the hash. If it is relevant, but not part of the hash, that is a bug. Building a project with different IDEs or Gradle versions and so on should never cause wing results. If it does, then somewhere is a bug.

that append mostly using the Cmake or android.mk.

so now i got a project that worked for nearly 5 years. And since the mess i can even run it on my old phonne. I cannot even build my C++ code. No gdb, no link. It is completly crazy.

I think a will stop working on Android. To much problem changing IDE version and gradle version.

We cannot even donwload old android studio version. It was working fine last months.
It like the jcanter disparition. How would not back up there information. This time i did not :unamused:

Not sure what you mean.
On Arquivos de download do Android Studio  |  Android Developers all previous AS versions are available for download.
And if it not worked, you should complain to Google.

And as I said, if the Android tasks do not properly recognize as up-to-date or not, you need to report it most probably to Google too which maintains AS and the AGP.

i cannot access it it always come back to the last version.
have a look.

I did before I wrote and it works perfectly fine, unless you say it downloads the new version with the filename of the old version.

Before we have a page that asked for acceptance and than we could go to the donwload page. i got “impossible de trouver cette page”.
So it is working for you but not for mee :grinning: google the magician d’OS and not d’OZ. But may be the same end.

Maybe complain to Google then if it does not work. :man_shrugging:
I also get the acceptance page, but after clicking “I consent” I get a list with all the old version with links.
Maybe you have some firewall that blocks the request getting that list or similar? :man_shrugging:

yes it is accecible for other language but not french. :grinning: :grinning:
But even in english it start from 33.1.1. Nothing before. It is like Jcenter archive :grinning: :grinning:

I should have used IOS rather than android :grinning: :grinning:

Still not sure what you mean, first I see is 2.3.2 and I don’t see a 33.1.1 anywhere.

Yes i am also able to see it in english and deutch at the first time if i change language it goes back to minimum 33.1.1 version or need to clean coockies and start again.

So i took the english version. there is no french and i do not think they have one.

Not easy. :grinning:

By the way i found the way to change Gradle User Home. good i can start working again.

thanks for your patience and help. :grinning:

1 Like

hi,

concerning the mixed up project. In fact project file are in user/user/appdata/Local//google folfders. And it may in this part that the mixed appends.

In fact gradle just manage the task and dependencies process . But do not store anythings about project. I cannot find any information about my 2 project in .gradle folder. But in user/user/appdata/Local//google i find a lot of folder containing file concerning each project.

Is there a way to remove Ă©very file related to one project in those folder ?

So when i do clean build or clean project in the terminal. What really append ?
Things are deleted or just project task are reseted to zero for full rebuild for example.

I start to anderstand the procees it is not clear yet for all but step by step. :grinning:

I have no idea what that folder is, where it is coming from or what is in there.
It also has nothing to do with Gradle, so is off-topic here.
A ./gradlew clean on the command line runs the clean task and it’s dependencies of your project. What those tasks do, depends on your build scripts and the plugins you apply.
Typically, it will just delete the build directory in your projects, but theoretically it could also take a photo with your camera and post it to Instagram. So theoretically it could also clean that folder if your project is configured like that.

So gradle provide the framework, manage the dependencies. But what is inside the build task depends on Android, because i use android studio.

Again, that you use AS should be irrelevant. Which IDE you use should not modify your build logic. What the clean task does depends solely on your build scripts. How they configure the task, or what plugins they apply that configure the task like the Android Gradle Plugin.

Sorry i am still i little bit confused. Certainly, my bad english.

I anderstand about the build logic(the sequence of task).
Then there is the build.gradle and the gradle wrapper and two step i the build process.

  1. the synchronization (for each taks there is a control of syntaxe and other control. for example the C++ version used by the NDK, SDK used, and JRE used).

  2. the build(compilation and linking and install). Will control the java code integrity, the allowed java function depending on the SDK used, and C/C++ to build the APK.

So there is in this process a step where android save the result. The class for java, the .so library for C/C++, the Libraries copied to the APK exct…
And this, i think, is done if the task is OK.

So, if the task id OK it is maked UP TO DATE, for the next build, and recorded some where.

So, each project got a tree structure where he know where to look for in the correct folder. So for deleting a project we just need to delete the tree structure and everything related to it. But it look like there is no such tools to do it.

So data related to a project will never be deleted. And clean just set the task from UP TO DATE to 0, for example.

That would be a good idea to allow developper to clean project rather than to have to delete everything and réinstall from scrach. Like i did.

I don’t know what you mean by “android”, whether you mean “Android Studio” or the “Android Gradle Plugin” or anything else, but it doesn’t really matter.

“synchronization” if you meant as done by the IDE just gets information about the build that is necessary to properly provide IDE features like code completion and so on. There is no explicit validation of any configuration done, it just happens that many things need to be configured to get the necessary information for the IDE and thus implicitly is “validated”.

A task has inputs and outputs.
Simplified it is like this:
Before a task is executed, a fingerprint of its inputs is calculated.
After a task was executed, a fingerprint of its generated outputs is calculated.
The next time the task is run, the fingerprint for the inputs and outputs is calculated.
If neither inputs changed, nor outputs changed, the task is UP-TO-DATE, if anything changed since the last task execution, the task is out-of-date and thus is rerun.

A clean typically deletes the build directory which usually is the place where the task outputs are stored and due to that the outputs changed and thus the tasks are out-of-date.

Even if Android Studio copies any task outputs anywhere else (I doubt that it does, but I don’t know) it is absolutely irrelevant for whether a task is up-to-date or not.