Failed to capture snapshot of output files for task
Asked Answered
Y

14

8

Error:Failed to capture snapshot of output files for task 'transformClassesWithDexForDebug' property 'streamOutputFolder' during up-to-date check.

Failed to create MD5 hash for file 'C:\Users\GauravZone\AndroidStudioProjects\ZopporoStore\app\build\intermediates\transforms\dex\debug\folders\1000\10000\instant-run_83dbc65f4e3a4cd278807c089695c6b352698791\classes.dex'.

I am getting these errors don't know why, all application working fine earlier but suddenly getting this error in my all applications when try to run projects

Yser answered 28/3, 2017 at 9:10 Comment(5)
Please add your code, to help us to understand how we can help you.Recommend
i m getting this error in all of my applications, previously all applications worked fine but now i am getting these error, this is not about code maybe its gradle problemYser
Uninstall your antivirus...Imidazole
If you're using react-native: I solved it by running my command line as administrator and running 'react-native run-android'Frisch
Just restart the android studio. It worked for me.Intoxicative
A
13

Screenshot

Disable your antivirus, and it will work.

Advantageous answered 31/3, 2017 at 6:0 Comment(1)
This should be the accepted answer. I had same problem with the QuickHeal antivirus program.Akmolinsk
M
8

This is a Gradle issue and you can find it here. So as of now just disable Instant Run. It worked for me.

Muirhead answered 29/3, 2017 at 13:11 Comment(0)
O
5

In android studio,

  1. Open the Settings or Preferences dialog: On Windows or Linux, select File > Settings from the menu bar. On Mac OSX, select Android Studio > Preferences from the menu bar.
  2. Navigate to Build, Execution, Deployment > Instant Run.
  3. Uncheck The box next to Restart activity on code changes.
Oversoul answered 6/7, 2018 at 16:36 Comment(0)
H
5

I Solved this issue in my react-native project by removing all npm cache

1.npm  cache clean --force
2.react-native run-android
Hemicrania answered 13/1, 2019 at 12:46 Comment(0)
A
2

Set multiDexEnabled true in your buildType release class in your build.gradle file

Analyse answered 28/3, 2017 at 9:23 Comment(3)
how can i set this?Yser
hi @Hemil Kumbhani i set multiDexEnabled true but it is not working same errorYser
try adding these dependency in your build.gradle file dependencies { compile 'com.android.support:multidex:1.0.0' }Analyse
M
2

Error:Failed to capture snapshot of output files for task 'transformClassesWithDexForDebug' property 'streamOutputFolder' during up-to-date check ::

Solution: Just rebuild the project and then sync the project with Gradle files, as mention below.

1. Click on Build -> Rebuild Project

2. Click on Tools -> Android -> Sync Project with Gradle Files

Mcgill answered 19/9, 2017 at 18:29 Comment(0)
M
1

I was also getting the same error. But when i disabled Instant Run, Gradle started building. But i agree with those who think this is a Gradle issue. And until it gets resolve, disable Instant Run.

Marrow answered 4/5, 2017 at 22:34 Comment(0)
S
1

follows steps: instant run(file->setting->build,execution,deployment->uncheck instant run) then compile it work properly.

Skindeep answered 5/2, 2018 at 12:28 Comment(0)
P
0

I've run into this issue after updating Android Plugin for Gradle to version 2.3.1. Rollback to version 2.3.0 helped for me, try setting classpath 'com.android.tools.build:gradle:2.3.0' in your top level gradle.build file.

Potter answered 21/4, 2017 at 9:29 Comment(0)
U
0

For me i had this error when i use my device as emulator . I did like that and it works :

       1.adb reverse tcp:8081 tcp:8081
       2.react-native start --reset-cache
       3.react-native run-android
Unhandled answered 11/1, 2019 at 9:8 Comment(0)
C
0

I faced the same issue and by disabling the QuickHeal Antivirus's virus protection, it worked for me fine.

Cremona answered 2/3, 2019 at 6:6 Comment(0)
C
0

Problem is gradle version. Update the gradle version to latest to resolve this kind of issues.

I have tried 'com.android.tools.build:gradle:3.3.2' is working for me. previously it was '3.1.0'

Chloris answered 7/1, 2020 at 6:18 Comment(0)
E
0

This issue comes when there are more than one process which is doing something with a file in your disk (whether it's your Jenkins job's workspace or Gradle's cache path or Gradle build folder that it creates) where these processes are trying to do something with a file and holds a lock.

If you have anti-virus, you may see this. Un-installing may resolve the issue but then you don't have anti-virus (it's better if you can set something in anti-virus to scan files periodically).

In my case, this issue only comes when I have a Jenkinsfile pipeline, where I'm running Gradle task for 3-5 projects in parallel (let's say Gradle is running an rpm task or build task) and when I'm running concurrent runs of this pipeline.

As you can see my pipeline code (Jenkinsfile Pipeline DSL: How to Show Multi-Columns in Jobs dashboard GUI - For all Dynamically created stages - When within PIPELINE section) is creating dynamic stage(s) and when I call it within pipeline section, I use parallel to run N no. of projects (that I can define in a hash/array) gradle tasks in parallel.

What I noticed is, all these runs (running in parallel) is running using my user-id (or some service account) and they are all using same Gradle version (4.3.1 in my case) and thus, they are using the same cache.

Running them in parallel alone --OR-- more realistic case would be running multiple pipeline runs of this pipeline job (running 5 project's gradle task in parallel) would probably land into this LOCK file condition.

You can probably solve this by setting a unique GRADLE_USER_HOME="~${WORKSPACE}/.cache" (i.e. use Jenkins job's workspace which is dynamically created and is unique) or even better by setting Gradle user home as:

dt_stamp=`date +%s`; ## set and pass this dt_stamp variable for Gradle user home before calling Gradle.
GRADLE_USER_HOME="~${WORKSPACE}/${dt}/.cache"`

This way, at least in Gradle's cache, you won't see any issues due to lock files (NOTE: You'll not be able to efficiently use Gradle's cache concept of being lazy (or not fetching artifacts/library dependencies from a binary repository like Artifactory each time) while using Gradle among many projects if you set GRADLE_USER_HOME to a dynamic folder value as it'd be like running gradle after clearing it's cache each time (for some it's OK if your build doesn't take much time and it's more cleaner way to build as well)).

When I tried to run just one pipeline run (which runs all 5 project's gradle task in paralle), the pipeline succeeds all the time.

Running multiple instances of the pipeline job (running 5 parallel builds in each run) lands into this file LOCK issue.

Error mesg when I ran many concurrent pipeline runs (each pipeline run - runs Gradle tasks in parallel on 5 different projects).

FAILURE: Build failed with an exception.


* What went wrong:

Failed to capture snapshot of output files for task ':rpm' property 'archivePath' during up-to-date check.

> Timeout waiting to lock file hash cache (/view/user123456_Team_Tools/vobs/space/test/folder1/Project1of5/.gradle/4.3.1/fileHashes). It is currently in use by another Gradle instance.

  Owner PID: 29003

  Our PID: 903

  Owner Operation: 

  Our operation: 

  Lock file: /view/user123456_Team_Tools/vobs/space/test/folder1/Project1of5/.gradle/4.3.1/fileHashes/fileHashes.lock


* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

-- OR --

You may also get this kind of error where a process is not able to delete a directory (while Gradle is in progress as the target folder/file may be in use by some other process)

FAILURE: Build failed with an exception.


* What went wrong:

Execution failed for task ':clean'.

> Unable to delete directory: /view/user123456_Team_Tools/vobs/space/test/folder1/project2of5/build/classes/java/main/org/syntax/jedit


* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


* Get more help at https://help.gradle.org

If you are really lucky (like me), then you'll probably hit this error as well:

Jenkins - java.lang.IllegalArgumentException: Last unit does not have enough valid bits &
Gradle error: Task 'null' not found in root project

See here for more details: Jenkins - java.lang.IllegalArgumentException: Last unit does not have enough valid bits & Gradle error: Task 'null' not found in root project

Extravagance answered 20/1, 2020 at 18:11 Comment(0)
B
0

Clearing the cache does fix it. But only once, if you stop the project and re run it, you ll end up with same error again.

Doing following fixes it for me,

cd android ./gradlew clean react-native start --reset-cache npm clean cache --force

Next, open two different terminals,

Run react-native start in one terminal and in second,

Run react-native run-android Hope it'll work for you as well.

Blavatsky answered 17/3, 2020 at 9:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.