Gradle build not executing because it can't find cache.properties - android

My gradle build in android Studio is failing because it can't access the cache.properties file. I have tried invalidating all caches and retrying but that did not work. I also reinstalled all the SDK tools. Here is the error I'm getting
Error:java.io.FileNotFoundException: C:\Users\Siddharth\AndroidStudioProjects\IntentAssignment.gradle\2.4\taskArtifacts\cache.properties (The system cannot find the file specified)
C:\Users\Siddharth\AndroidStudioProjects\IntentAssignment.gradle\2.4\taskArtifacts\cache.properties (The system cannot find the file specified)
Blockquote
Any advice on what to do, here is the complete console output:
FAILURE: Build failed with an exception.
* What went wrong:
java.io.FileNotFoundException: C:\Users\Siddharth\AndroidStudioProjects\IntentAssignment.gradle\2.4\taskArtifacts\cache.properties (The system cannot find the file specified)
C:\Users\Siddharth\AndroidStudioProjects\IntentAssignment.gradle\2.4\taskArtifacts\cache.properties (The system cannot find the file specified)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 0.747 secs

delete gradle folder, quit Android Studio and Start again fixed this problem for me

run cmd
write %temp%
then temp folder open delete all file in temp then rebuild your project
hope this will solve your problem

After Search i found this answer and worked for me
thanks to #Salam El-Banna and #Naveed Ahmad
You don't have to delete all .gradle folders and no need to reinstall Android Studio.
I have the latest version of Android Studio and I faced that problem, the only thing that worked for me is to:
1- Navigate to
C:\Users\user.gradle\caches\2.x\
2- Copy the folder scripts , scripts-remapped and paste it somewhere safe just in case anything went wrong you will place it back
3- Delete this folder scripts and scripts-remapped from the directory C:\Users\user.gradle\caches\2.x\
4- Sync Project with Gradle Files and you are done.
When you sync your project Android Studio will generate new cache files.
It worked for me I hope it will work for you.
reference:
Cache.properties (The system cannot find the file specified)

Delete your Gradle folder
Invalidate cache and Restart
Simply these steps fix your issue.

Related

update failed java.io.FileNotFoundException

i updated my ide to letest version after update i opend project on which i was working before update but it gave error but when i opend other projects there had no error
please help Thank you
update failed for AnAction(com.intellij.execution.ExecutorRegistryImpl$ExecutorAction) with ID=Run
java.io.FileNotFoundException: E:\Android\WhatsApp\app\build\intermediates\apk_ide_redirect_file\debug\..\..\apk\debug\output-metadata.json (The system cannot find the file specified)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at java.base/java.io.FileReader.<init>(FileReader.java:75)
just clean project and make a build
It is solved by just rebuild project
Build → Rebuild project
Workaround: if you encounter this error generating an APK, first clean the project (Build -> Clean project)
Open your project.
If your project files are not loaded and instead you see: 'Loading...' cancel Sync Gradle by clicking on X at the bottom, this should show your files back.
Clean Project: Build -> Clean Project
Rebuild Project: Build -> Rebuild Project
In my case, I was unable to Clean Project as well as Sync Gradle Files, So
Eventually I was about to give up, but then I went to
AndroidStudioProjects/project_name/app/build/intermediates/apk_ide_redirect_file/debug in the file explorer and found a file named redirect
That file contained the following information
#- File Locator -
listingFile=../../apk/debug/output-metadata.json
From here, I tried to locate the path mentioned in this file and I was unable to find itSo I searched output-metadata in the file explorer from AndroidStudioProjects/project_name and I found a bunch of output-metadata files, I copied the first one and pasted it in the mentioned location, and then everything worked perfectly
Now I don't know wether this is the right way to solve this or not, but it worked...
Hope it helps you...

Test drive on flutter: android.jar file not found

I'm just trying to run the first app and this is what happens:
FAILURE: Build failed with an exception.
What went wrong:
A problem was found with the configuration of task ':app:processDebugResources'.
File 'C:\Users\XXXX\Appdata\Local\Android\sdk\platforms\android-28\android.jar' specified for property 'androidJar' does not exist.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 15s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
The file is on the android-29 folder! what should I do?
This error might occur because of android.jar is in another folder
Try opening
C:\Users\XXXX\Appdata\Local\Android\sdk\platforms
and then look
for a folder named android-29 or android-27 and you should be able to find android.jar in that folder just copy that file and paste it into to android-28
Image Please update your android sdk.
You don't have install api 28.
Please open your android sdk and install android sdk 28.
Not only android.jar is missing from my android-xx folder, then copy android.jar from other folder could solve this problem but I still have another problems when combine.
So I do a workaround
First, I delete this android-xx folder from Android\sdk\platforms
Then, I create a new empty project
Next, inside app\build.gradle of new project, I set both compileSdk and targetSdk to xx
Sync and run new project
Finally, android-xx will contains all the files
I dont know if delete the old android-xx before create new project is required or not. but I deleted it to make sure their is no other problem when replacing file
For some reason, android.jar is't automatically downloaded or built when installing specific Android SDK versions. This oversight means Flutter cannot find the android.jar, since it doesn't exist.
One solution, after installing the SDK version, is to manually download the android.jar for your desired SDK version from the following GitHub repository:
https://github.com/Sable/android-platforms
Make sure to put the android.jar file in the correct location, replacing XX with your version number:
Windows
C:\Users\XXXX\Appdata\Local\Android\sdk\platforms\android-XX\android.jar
OS X
Users/<username>/Library/Android/sdk/platforms/android-XX/android.jar

The specified project directory ''" does not exist

Ever since I have upgraded my Android Studio 3.0.1 to 3.1 I am not able to run the project.
Executing task 'assemble'..
FAILURE: Build failed with an exception.
* What went wrong:
The specified project directory '' does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED in 0s
The specified project directory '' does not exist.
15:52:35: Task execution finished 'assemble'.
If you are using IntelliJ with Gradle, you may need to unlink a non-existent module in the Gradle tab.
The issue might also be caused by an empty 'Gradle project:' field under:
'Run'
-> 'Edit Configurations...'
-> 'Gradle'
-> 'NAME OF YOUR CONFIGURATION'
-> 'Configuration'
-> 'Gradle project:'
Filling out this field by selecting the root directory of my application (an clicking on 'Apply') resolved the issue for me.
Delete .idea and .gradle folders and try to re-import the project. I had refactored my project name and I ran into the issue and deleting .idea and .gradle folders and re importing worked as it clears the meta data of project configuration for intellij or android studio.
Navigate to "File" and select "Invalidate Caches and Restart" from the drop down. After Android Studio restarts, your project should run.
have same issue
I copy an already existing project and try to run it and got this error
I fix it by
Enter to the settings.gradle file and change the "rootProject.name" to my new project name
If this not the issue than
2) from left side press on Gradle
press on project that failed to build and remove it
maybe you will need to restart the intelij after

Android studio BUILD FAILED In my Application shows error java.io.IOException: Could not delete path

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithProfilers-transformForDebug'.
> java.io.IOException: Could not delete path
Myapplication\app\build\intermediates\transforms\profilers-transform\debug\jars\1\10\226ac48e5c8c6b8707c7d76c6056e5800dee24de.jar'
I have use android studio 2.4.
please suggest solution regarding above issue,thanks in advance!
Try deleting the directory or the file manually.
I guess some of the files in the target build directory is open in another tool you use. Just a file handle open in the folder which has to be cleaned. The build task 'clean' wants to delete all the files in the build directory(normally 'target') and when it fails, the build fails.
I had the same error, tried deleting the directory It didn't work. So this is what I did. I just copied all my project files except the "Build folder and "Build Folder" in App to a new directory and I opened the project from the new directory and it worked perfectly.

Cannot build CastVideos-android, Error: Bad pathname

I have cloned from github both the respositories CastVideos-android and CastCompanionLibrary-android to my AndroidStudioProjects folder with the names 'CastVideos' and 'CastCompanionLibrary'. When I attempt to build CastVideos, in Android Studio I get
Gradle 'CastVideos' project refresh failed
Error:Bad pathname
When I run 'gradlew.bat build' in the CastVideos directory, I get the below:
C:\Users\Tim\AndroidStudioProjects\CastVideos>gradlew.bat build
Relying on packaging to define the extension of the main artifact has been depre
cated and is scheduled to be removed in Gradle 2.0
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'CastVideos'.
> Could not normalize path for file 'C:\Users\Tim\AndroidStudioProjects\CastVide
os\build\intermediates\exploded-aar\CastVideos...\CastCompanionLibrary\unspecifi
ed\debug'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 7.701 secs
C:\Users\Tim\AndroidStudioProjects\CastVideos>
This is my first attempt at using Android Studio after developing with Eclipse so I am a bit lost. Any suggestions?
I think I know why. It is a Windows thing. It seems that Windows does not realize that '..' mean upper directory. that is why you have this path "C:\Users\Tim\AndroidStudioProjects\CastVide os\build\intermediates\exploded-aar\CastVideos...\CastCompanionLibrary\unspecifi ed\debug" I am running on the mac which seems to be working fine
I would suggest that you copy the whole CastCompanionLibrary into your CastVideo directory and then change ..:CastCompanionLibraries to :CastCompanionLibraries
Changing relative paths from ..: to ./..: in both build.gradle and settings.gradle worked for me on Windows.

Categories

Resources