update failed java.io.FileNotFoundException - android

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...

Related

Clean project error with databinding: Unable to delete file androidx.databinding.library.baseAdapters--setter_store.json

I use Databinding. Sometimes while I make changes project may be broken. Then I go to Build -> Clean project & Re-Build project. And I get some strange error:
Unable to delete file: {path_to_project}\app\build\intermediates\data_binding_dependency_artifacts\debug\dataBindingMergeDependencyArtifactsDebug\out\androidx.databinding.library.baseAdapters--setter_store.json
Every time I don't know how to fix it, because I get this error on clean or rebuild. Even if I make Invalidate caches / Restart the problem isn't gone.
If I try to delete this file manually I get error that file is using by another process. Then I close project and successfully delete this file. But when I open the project and build it I get the same error described above.
As I can see the problem is about databinding, but I'm not sure because I saw the same problem with other files from other users on StackOverflow. Sometimes problem is gone by itself, but usually it isn't. Maybe the problem occurs because of errors in layout files, but how to find it out if there is no errors in build log.
Has anyone meet that error? Any ideas how to fix that situation without crush whole the project in undefined time range?
I close Android Studio, delete the app\build folder then reopen Android Studio. Note that all instances of AS must be closed for Windows to let you delete the build folder.
Put Below command in Android Studio terminal.
gradlew --stop
So, the problem is still here but all answers don't solve it. Project doesn't compile for a reason, usually it's some kind of mistake, and if you just delete build folder (which contains file Android Studio is unable to delete) it will not solve problem.
When you are trying to compile project you may get a dozens of errors in generated files (databinding, room, etc). Unfortunatelly, errors are not displaying in the usual window, but if you expand this generated files with errors, you probably will see the real problem, your mistakes you didn't fix when was changing your classes related to generated files. Just fix these mistakes and compile project again. Note: you probably should to look at warnings too.
But if you already got error Unable to delete file you won't see errors in generated files. You need to restart Android studio (if it won't help, you need to delete app\build) and try to compile your project. After that you will find generated files with errors in build tab.
Hope it helps!
First follow this 4 steps
Remove your file generated (build folder)
Clean your project ( simply run cmd command - > gradlew clean)
Invalidate cache and restart Android Studio
Restart computer
If not helpful please try following steps
Gradle sync;
Reinstall Java JRE & Java SDK;
Reinstall the latest version of Android Studio
Rolling back to the previous AS version
Invalidate cache and restart Android Studio
Delete the gradle and .gradle directories in the project directory;
Delete the .gradle directory in your directory;
Run gradlew clean ( simply run cmd command - > gradlew clean)
I have the same problem, and tried the method mentioned above. I could not find the related class in the error message when I searched in the project directory.
In the end, I suspected that it maybe ~/.gradle problem, and then recompile after deleting, and finally solved.
mv ~/.gradle ~/.gradle_bak
Try to disable the daemon and parallel build in gradle.properties
org.gradle.daemon=false
org.gradle.parallel=false
I tried most of the solutions above but seemed not to find them working.
But here is what I did to get my project up and running again.
I am assuming this is happening because you are using dataBinding.
browse to the dataBinding section in your app gradle file
now disable dataBinding by setting to false.
next, rebuild your project and you will notice an error about something to deal with missing a dataBinding in xml file.
Next enalble dataBinding by setting to true this time.
next, rebuild your project.
It should have cleared that strange error.
Forgive me for the strange explanation but am new to contributing to stackoverflow.
It is because of databinding cache issue. We need to delete that cache by disabling it first. I solved the issue after changing the properties of the gradle.properties file:
org.gradle.daemon=false
org.gradle.parallel=false
android.enableBuildCache=false
org.gradle.caching= false
android.databinding.enableV2=false
and
dataBinding {
enabled = false
}
Clean and rebuild the project. After rebuilding it will show errors. Then change all the configuration (make all properties true) and clean, rebuild. It will work absolutely fine.

How to solve Specified AAPT2 executable does not exist on Android Studio 3.2

I've an issue with Android Studio. I'm trying to use it on Windows but I've trouble during the project's build process.
First, notice Android Studio is installed on my secondary HDD.
When I try to build/run my project I get this error:
Specified AAPT2 executable does not exist:
C:\Users\Rémi\\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\35960bdffa2420a45dff6ec260c07fa9\aapt2-3.2.0-4818971-windows\aapt2.exe
And indeed there is no aapt2.exe here.
But I've found this .exe here:
H:\Logiciels\AndroidStudioSDK\build-tools\28.0.2\aapt2.exe
and a previous version here:
H:\Logiciels\AndroidStudioSDK\build-tools\27.0.3\aapt2.exe
I've tried to fix this issue by changing the build tools version by setting File > Project structure > Modules > App > Build Tools Version. This option was empty and I chose 28.0.2 but that doesn't change anything.
Thanks for reading.
P.S.: This question is not the same. My error is different and I have google() in my Grable file.
I solved it by deleting the directory under which it expected the aapt2 executable, e.g. C:\Users\support\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\4c1f5b7dca1d5d378360be7f3fd9726a\aapt2-3.2.1-4818971-windows and then did a clean in Android Studio Build>Clean Project.
Afterwards it appears to have downloaded this again, with the missing executable, and now works perfectly.
I had the same issue. I resolved it by opening my file browser and navigating to this folder
C:\Users\(My User Name)\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar
Opening this folder and viewing its contents, I deleted the folder labeled 81c3666e327fa931c773a52e6cb0b3b7 which for you would be 35960bdffa2420a45dff6ec260c07fa9.
After this I went back to Android Studio and clicked the Build menu, and used the Clean Project option, followed by the Rebuild Project option.
I no longer get this error, or all the debug errors that say the Java package "R" did not exist.
I hope this helps.
Following solved my issue
under jar folder there are 3 folders, one of the folder consists of the aapt2.exe in it.
I copied that file to other folder where I am getting error.
ex:
path of jar: C:\Users\umabhavania\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar
error path: C:\Users\umabhavania\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\a57a698502c21bfe8cfc3ed6eb102b39\aapt2-3.2.1-4818971-windows
copied aapt2.exe file from 57f15fb82085ec9389484ff7e041344f folder to a57a698502c21bfe8cfc3ed6eb102b39
Hope this helps..
I resolved this issue by removing that folder
Go to that path -> Delete
Ex: C:\Users\Rémi.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\35960bdffa2420a45dff6ec260c07fa9\aapt2-3.2.0-4818971-windows\aapt2.exe
In this go to "C:\Users\Rémi.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-4818971-windows.jar\" and delete 35960bdffa2420a45dff6ec260c07fa9
Clean Project and Build
1- enter to the file like
C:\Users\4khalil\.gradle\caches\transforms-1\files-1.1\aapt2-3.3.2-5309881-windows.jar\6abc6a09978228d11497e7ca9c3de2c9\aapt2-3.3.2-5309881-windows
then if you find aapt2.exe.dat, delete the extension .dat to be aapt2.exe
and the problem will be solved.
You can use 'invalidate cache and restart'.
In Android Studio, go to File menu -> click Invalidate Caches/Restart.
Just chnage the gradle version in your build.gradle file in android folder.
For example mine was 4.1.0, changed it to 4.1.1
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
just copy paste this file aap2.exe get it from a friend or somewhere at this location and paste it on the same folder found in yours in .gradle C:\Users\Dina.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\8735df2342ae4ae127451389faa5e1f1\aapt2-3.2.1-4818971-windows\
then build and then the build will complete successful.
I didn't know how to attach the file in my answer I am new to stack overflow.

"AndroidManifest.xml doesn't exist or has incorrect root tag" Error

I am new to AndroidStudio AND Gradle.
I imported a project from eclipse, created a module, and tried to run the project, but I got this error:
AndroidManifest.xml doesn't exist or has incorrect root tag
I have been looking at this previous solution for it:
How to build an android library with Android Studio and gradle?
But that solution is WAY too advanced for me.
Could someone please help me understand in simpler terms what is going wrong and how I can fix it?
Thank you!
Update after one of the answers:
These are the options I have under the build menu:
clicking on Sync project with Gradle files button will solve your problem.
That button is under File section on Android Studio 3.6.1
Close your Android Studio
Goto C:\Users\user\.AndroidStudioX.X\system and DELETE the cache
folder
Launch the Android Studio
Goto Build (menu) -> Clean Project when done click the
Build (menu) again and click rebuild project.
That should solve the problem.
For me the issue went away once I opened the android folder of the project in Android Studio to run the project.
So basically, because I was trying to run the Android project from the Root folder, it gave me the error. We need to run the project by selecting the android folder of the project only.
Hope this helps someone!
Click on File > Invalidate Cache/Restart, and that's it. Your project should start working.
For me clicking on Sync project with Gradle files button did not solve the problem alone.
After Syncing project with Gradle files, I explicitly had to invalidate the cache and restart studio. Only after this action, the red cross-mark over configuration disappeared and everything started working.
In my case, my android project got corrupted and some of the files were showing characters, binary numbers, etc. I tried the following solutions
Invalidate & Restart
Rebuild Project
Sync with Gradle File
But none of the above solutions worked for me.
Then I just deleted the cache folder under C:\Users\username\.AndroidStudio3.6\system
and all the invalid characters disappeared and the actual contents of all the files were displayed. This solution worked for me.
Every Android project needs a file called AndroidManifest.xml to tell Android about itself. Either your project doesn't have one, or it's not in the place that Android Studio expects it to be. Try to find it, and move it to the root folder of the project.
1.Check whether the manifest file is there or not.
2.If it is there, check whether the package name is correct or not..
3.If you project has small number of classes, then you create new project in android and then copy paste your code from eclipse. It will be simple. But it is recommended only for small project.
And finally click 'Sync' in the Gradle file. Followed by Rebuilding the project will do a trick.
In my case the Manifest file seemed to be corrupted or maybe its meta data. Trying to open it in Android Studio will show some characters that you see when opening a binary file with a text editor, for ex. Anyway, my project is under Git, so I just deleted it and restored it back, problem fixed.
Go to C drive click User then select your android studio folder then select System find Cache folder and delete this folder before doing this close your android Studio.It will surely work.
I also had this problem, things I tried:
I delete user->gradle-> delete cache folder
Android studio-> file-> Invalid cache/restart
Using my problem is get resolved
I also had this problem, things I tried:
Syncing the file with gradle
Invalidate/Restart
But the problem was still there in the manifest folder-> manifest.xml file it had only 1 line.
So I went to User-> your_username -> Android Studio v -> caches and Deleted the cache folder.
Started Android Studio, and my problem was gone.
But I am not sure which of these might solve yours.
I have opened AndroidManifest.xml in file editor. Add some letters, save it, then android studio found AndroidManifest.
After this I can build project successfully
if your AndroidManifest.xml looks wierd than you can try checking local history or git history. by doing that you can copy paste the previous version AndroidManifest.xml
Experienced that too, there is a line on your manifest code that's incorrect, simply go through it and make necessary corrections.

android studio gradle refresh failed (The system cannot find the file specified)

Error:Could not open initscript class cache for initialization script
'C:\Users\Subash\AppData\Local\Temp\asLocalRepo2.gradle'
(C:\Users\Subash.gradle\caches\2.2.1\scripts\asLocalRepo2_cd0g6mnzdabuvxgeqlhhrxv0q\InitScript\initscript).
java.io.FileNotFoundException:
C:\Users\Subash.gradle\caches\2.2.1\scripts\asLocalRepo2_cd0g6mnzdabuvxgeqlhhrxv0q\InitScript\initscript\cache.properties
(The system cannot find the file specified)
UPDATE:
Check my answer here for full details
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.4\
2-Copy the folder "scripts" and paste it somewhere safe just in case anything went wrong you will place it back
3-Delete this folder "scripts" from the directory C:\Users\user.gradle\caches\2.4\
4- Sync Project with Gradle Files and you are done.
When you sync your project Android Studio will generate new cash files.
It worked for me I hope it will work for you...
I don't know why a great developer as Google can't manage this issue by them selves it is very easy to delete the cached folder and regenerate it programmatically. Any way just navigate to C:\Users\user.gradle\caches\ and open the latest version folder, then delete the scripts folder. Go to android studio and sync project, that should do it.
Exit Android Studio, remove the Gradle cache folder which path is in the error message, and restart.
You could try to delete this : C:\Users_USER_.gradle\caches_GRADLE_\scripts_XXX_\InitScript\initscript\cache.properties.lock
I had the same problem and after deleting it all works fine.
Another common problem with Gradle is synchronization which is solved adding the correct path of JDK but this is another story.
I hope to help.

Android Development - Conversion to Dalvik format failed with error 1

So I'm dipping my toes into this area for the first time - i followed instructions to install the android SDK and eclipse plug in. I created a blank new android project and I get the following build errors:
[2011-01-08 16:34:55 - xxx]: Dxno classfiles specified
[2011-01-08 16:34:55 - xxx] Conversion to Dalvik format failed with error 1
I've googled the problem and tried to clean and rebuild, or hitting F5 on the project in the explorer but the issue remains. I've verified the build paths and the libraries to make sure only Android 2.3 is there but still get this issue.
I have also tried to load a sample project and I get the same error.
Any ideas?
This problem happens when the java files in the Eclipse project are not compiled to class files. The message indicates that the Android SDK cannot proceed to convert these classes to dalvik format because it could not find them. To solve this problem:
Verify that the src folder is in your build path ( check under "Project Properties" -> "Java build path" ). If this is not the case right-click on the src folder, go to "Build path" and click on "Use as source folder".
Verify that under "Project properties" -> "Builders" you can find "Java builder". If this is not the case close the project and with a text editor open the file .project present in the root folder of the project itself. Add under <buildSpec> the following lines:
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments></arguments>
</buildCommand>
After performing the actions described above, re-open the project and proceed to rebuild it by clicking on "Project" -> "Clean"
I fixed this - none of the above helped.
What i did was delete eclipse, download the latest one and reinstalled the ADT plugin and it works now.
Simply edit the "project.properties" file and comment the line:
proguard.config=proguard.cfg
to be like the following:
#proguard.config=proguard.cfg
then clean the project. Hope this will export to APK successfully.
The answer is detailed here. Try these steps, and it should work out.
I had the same problem: try to clean the project (Project -> Clean...). Eclipse will recreate the right bin directory.

Categories

Resources