Gradle sync failed: removeContentEntry: removed content entry url '...' still exists after removing
Asked Answered
B

16

53

I have a gradle sync fail for my little project that seems to be quite rare as google did not find anything about it. I get the error: Gradle sync failed: removeContentEntry: removed content entry url 'file://C:/Users/BenutzerA/IdeaProjects/EtikettenScanner1/app' still exists after removing (2 s 337 ms)

A clean build did not help. "Invalidate caches /Restart" did not help. So far this seems the only project that suffers from this problem. I switched to 3 other projects and they all build without problems.

Project uses Kotlin, Android, Google-Services

Anyone has a hint for me?

Part of idea.log:

021-02-15 20:39:10,076 [4053612]   WARN - e.project.sync.GradleSyncState - removeContentEntry: removed content entry url 'file://C:/Users/BenutzerA/IdeaProjects/EtikettenScanner1/app' still exists after removing 
java.lang.IllegalStateException: removeContentEntry: removed content entry url 'file://C:/Users/BenutzerA/IdeaProjects/EtikettenScanner1/app' still exists after removing
    at com.intellij.workspaceModel.ide.impl.legacyBridge.module.roots.ModifiableRootModelBridgeImpl.removeContentEntry(ModifiableRootModelBridgeImpl.kt:209)
    at com.android.tools.idea.gradle.project.sync.setup.module.common.ContentEntriesSetup.removeExistingContentEntries(ContentEntriesSetup.java:47)
    at com.android.tools.idea.gradle.project.sync.setup.module.ndk.NdkModuleCleanupStep.cleanUpModule(NdkModuleCleanupStep.java:42)
    at com.android.tools.idea.gradle.project.sync.idea.data.service.NdkModuleModelDataService.onModelNotFound(NdkModuleModelDataService.java:78)
    at com.android.tools.idea.gradle.project.sync.idea.data.service.ModuleModelDataService.onModelsNotFound(ModuleModelDataService.java:64)
    at com.android.tools.idea.gradle.project.sync.idea.data.service.ModuleModelDataService.importData(ModuleModelDataService.java:49)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.doImportData(ProjectDataManagerImpl.java:252)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:120)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:206)
    at com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManagerImpl.importData(ProjectDataManagerImpl.java:213)
    at com.android.tools.idea.gradle.project.sync.idea.IdeaSyncPopulateProjectTask.populateProject(IdeaSyncPopulateProjectTask.java:66)
    at com.android.tools.idea.gradle.project.sync.idea.ProjectSetUpTask.doPopulateProject(ProjectSetUpTask.java:95)
    at com.android.tools.idea.gradle.project.sync.idea.ProjectSetUpTask.onSuccess(ProjectSetUpTask.java:65)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.handExecutionResult(ExternalSystemUtil.java:559)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.executeImpl(ExternalSystemUtil.java:539)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.lambda$execute$1(ExternalSystemUtil.java:373)
    at com.intellij.openapi.project.DumbServiceHeavyActivities.suspendIndexingAndRun(DumbServiceHeavyActivities.java:21)
    at com.intellij.openapi.project.DumbServiceImpl.suspendIndexingAndRun(DumbServiceImpl.java:185)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:373)
    at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4.run(ExternalSystemUtil.java:644)
    at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:962)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsync$5(CoreProgressManager.java:472)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:235)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:178)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:658)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:610)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:65)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:165)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:235)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
    at java.base/java.lang.Thread.run(Thread.java:834)```
Babysitter answered 15/2, 2021 at 19:52 Comment(4)
What IDE version do you use? Have you tried to remove all IDE related data (.iml file and .idea folder) and reimport project?Javelin
@Javelin Removing those files helped me to solve the problem, it works fine now, thank you very much. I will remember that for the future! My IDE-version: IntelliJ IDEA 2020.3.2 (Ultimate Edition), Build #IU-203.7148.57, built on January 26, 2021Babysitter
Did you ever figure it out? I am facing the same cryptic error message.Spann
See youtrack.jetbrains.com/issue/IDEA-294971/… for the open bug that is going nowhere.Sepulture
E
30

Intellij Idea 2022.1.4 (Ultimate edition)

My solution is to delete files:

  • project-dir/.idea/compiler.xml
  • project-dir/.idea/modules.xml

restart/reload the Gradle project

Ela answered 21/7, 2022 at 18:49 Comment(2)
Thanks for the hint. Didn't find the modules.xml, however removing gradle.xml helpedGliadin
remove .idea file helpedScout
C
22
  1. Remove ".idea" folder.
  2. Reopen the project. The problem should be gone.
  3. Restore the previously deleted ".idea" folder.
Comfortable answered 16/1, 2023 at 13:43 Comment(1)
Worked for me (but I skipped step 3). I tried the other solutions by just removing the .xml from the .idea folder but it didn't work. I'm on Android Studio Flamingo | 2022.2.1 Patch 1. With gradle 7.4 and AGP 7.3.1Overslaugh
O
5

Delete ".idea" folder. Helps already twice for me, IDEA 2022.1.4 Ultimate

Onepiece answered 17/12, 2022 at 21:22 Comment(2)
Same, deleting .idea and reimporting with gradle (automatically detected by intellij) worked for meOnomasiology
In the end this is the only thing, that actually helped. Restarting, invalidating caches did not, didn't want to change the IntelliJ version and there was no <content .../> in my *.iml files. So deleting the .idea folder altogether resolved the issue.Suborder
E
4

Just in case you miss it in the initial comments, when I had this problem (in another project using IntelliJ IDEA directly) removing the .iml file and the .idea directory and re importing the project worked like a treat for me.

Erotica answered 24/6, 2022 at 17:8 Comment(1)
yes, just deleting/renaming .idea folder (just restarting IDE) worked for me as well.Bacchae
B
3

What worked for me was to remove a duplicate entry in .idea/modules/myproject.test.iml this entry was duplicated :

    <content url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/test">
  <sourceFolder url="file://$MODULE_DIR$/../../build/generated/sources/annotationProcessor/java/test" isTestSource="true" generated="true" />
</content>
Brunhild answered 13/1, 2023 at 0:23 Comment(0)
T
2

The only thing that worked for me was to simply rename the folder that contained the Android Studio project. Actually, the first thing I did was just checkout my code from the git repo into a different folder. The code was exactly the same as the original folder causing me this issue. So if we say that my original folder was called X, I then renamed the "bad" folder to "X.BAD" and renamed the new "good" folder to X. After swapping them I noticed that the fresh checkout of the code sitting in the folder named X now has this problem, but the project in X.BAD works just fine.

So somehow AndroidStudio must keep some information about these projects outside of the actual project folder. Clearly this is an AndroidStudio bug. I created a bug report. If people are experiencing this, please go visit and let them know about it. Thanks.

https://issuetracker.google.com/issues/320857594

NOTE: This is on AndroidStudio 2023.1.1 Patch 1

Trela answered 19/1 at 15:13 Comment(0)
J
1

There is solution helped me:

  • Build needle build variant via terminal (./gradlew assembleRelease for example)
  • After change build variant to needle via android studio (to Release in this example) May be it helps other people
Jardine answered 16/11, 2021 at 10:24 Comment(1)
After running "gradlew assembleRelease" with success, still no Build Variants are displayed and project sync still fails with same error. In my case the folder it is trying to release is a CMake project folder checked out from git that should not be removed anyway. Anyone knows why gradle is trying to delete projects in the first place?Anastassia
L
1

I solved this problem like this:

  1. Export project to a zip file
  2. Delete old folder (make a backup)
  3. Unzip the exported project
  4. Run Android Studio again from that folder
Lenticel answered 12/6, 2022 at 22:50 Comment(0)
T
1

The best solution I use is to Invalidate Caches and restart. After the restart the project syncs again without the error.

Tillietillinger answered 8/10, 2023 at 5:42 Comment(1)
Didn't work eitherSimonne
S
0

No answer was of help to me. Neither repairing the IDE, removing all the build directories, etc. Until I tried with a different version of Android Studio.

So, my suggestion, try opening the project with a different version of Android Studio.

Sinclare answered 16/11, 2023 at 0:9 Comment(0)
B
0

In Android Studio, click on File -> Invalidate Caches... -> Invalidate and Restart

enter image description here enter image description here

Buford answered 3/1 at 19:51 Comment(0)
A
0

In my case the solution was very complicated. Deleting (project).iml and .idea (and .gradle), repairing IDE and even invalidating caches did not work. Then I restored the .idea directory from git, removed all files except the "modules.xml" and the "modules" subfolder - first from the repository, then locally - and restarted the IDE. It reported a lot of errors, I had to restart it again, but finally I could rebuild the project. (It's funny that the modules.xml file and modules subfolder are gone after rebuild) - Android Studio Iguana | 2023.2.1

Albuminuria answered 18/3 at 10:49 Comment(0)
D
0

In my case, I tried all the given steps above. I could not get the solution what I then did was delete the .gradle and .idea folders from the storage restarted the project on Android Studio did file > repair IDE on the prompt restarted the IDE then everything downloaded and it now okay

Drippy answered 14/5 at 12:34 Comment(0)
C
0

TLDR: downgrade Android Studio from Koala to Jellyfish

I have this error using Kotlin Multiplatform and updating compose-resources library from 1.6.2 to 1.6.11.

This error was related with AndroidStudio, because build app from terminal works fine ./gradle assembleRelease.

Just FYI, I posted my full explanation here:

https://github.com/JetBrains/compose-multiplatform/issues/4359#issuecomment-2183965849

Crappie answered 22/6 at 10:5 Comment(0)
R
0

Deleting the .gradle and .idea directories made it works for me. Reimport the project and invalidate IDE caches didn't make it work.

Roughandtumble answered 11/7 at 10:12 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Planometer
D
-1

If you have been upgraded to the new version of Android Studio, We should go back to the old version.

Dennisedennison answered 24/1 at 3:16 Comment(3)
Seriously? This worked for you?Simonne
Yes, it worked in my situation. I try to another way so clean the cache, and validate,... But they do not help me. After that, I try to download a different Android Studio and It works perfectly.Dennisedennison
I initially downvoted, but actually, if you are using jellyfish, it seems to be broken. Just use iguana. I literally downgraded to iguana and the project imported successfully immediately.Starobin

© 2022 - 2024 — McMap. All rights reserved.