I am building a project for quite a while and my friend recently started working on it as well. We are using github, we integrated it into android studio and everything seemed to be fine. However, after his first push, my build broke.
FAILURE: Build failed with an exception.
What went wrong:
failed for task ':app:compileDebugJavaWithJavac'.>java.io.FileNotFoundException:C:\Users\user\.gradle\caches\2.10\classAnalysis\cache.properties (System cannot find the given file)
I looked at other StackOverflow threads as well, but none of the fixes worked for me. Any ideas? Tell me what to include, I ll include in comments.
Thank you in advance :)
I had this same problem and I was able to find a resolution from
Cache.properties (The system cannot find the file specified)
Use the File manager and navigate to the 2.10 folder, You will then want to copy the classAnalysis folder and paste it somewhere safe (I pasted mine into the folder up from 2.10, the caches folder). Once its in a safe place delete the version of it inside the 2.10 folder. Then go to android studio and click Build>Make Project. It should regenerate that folder. For me after it generated it I had the same error in the jarSnapshots folder. Did the same thing again and it worked out for me.
Related
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.
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.
I had created a project with Android Studio and pushed it to bitbucket. After few weeks now I have cloned it on different machine to resume my work. I imported the project in Android Studio and now I keep getting this error.
Migrate Project to Gradle?
This project does not use the Gradle build system. We recommend that you migrate to using the Gradle build system.
More Information about migrating to Gradle.
Don't show this message again.
I have the gradle directory in my project. I tried using the option of use local gradle distribution and pointed it to downloaded gradle-1.10 but I still keep getting the same error.
First of all I would remove following files/directories from your project-folder:
bin/
build/
.idea/
.gradle/
projectname.iml
Then try to import the project again in AndroidStudio. This usually works for me, and to avoid that in the future, adjust the .gitignore file properly.
If the first tip does not help: have you tried downloading a more recent gradle (1.12) locally and point to that directory? (Don't point AndroidStudio to download, but do it yourself first).
You are not using a gradle-wrapper are you?
If you haven't started coding in your new machine, the simplest way would be to just delete your project directory, and use "import from VCS".
Not worth the time to find the "solution", trust me. I tried. Almost 2 years since you asked the question, and people are still getting the issue, then this problem is obviously not worth solving.
Most probably you have git checkout a parent directory of a working android project.
Close freshly checked git project
Open Project
Navigate to the git checkout directory
Select a sub directory inside the git checkout project and that is the intended android project for you
I ran into the same problem. For me the problem was my sttings.gradle was cleared. After adding incude: 'modulename'. It worked for me
I fixed this issue with the following steps:
Make sure that the following two files are in your project directory. If not, create a new one with reference of your other Android projects. These are default auto-generated files.
settings.gradle
build.gradle
If it is still showing any errors when you open your project, restart your project by selecting file/(invalidate /restart).
I had the same problem and I managed to fix it by invalidating caching and restart File - > Invalidate caches and restart
I'm a newbie with both android and eclipse, so if you can help me, please don't assume that I know very much.
I have downloaded kankan.wheel and I'm trying to run the demos. I built the demo project in eclipse, using Android project from existing code. The project compiles without error, but crashes with a NoClassdefFoundError exception when I try to run it. The main menu comes up, but when I press a button to run a demo, the app crashes. I posted a screenshot of the the error message in context at https://dl.dropboxusercontent.com/u/24746182/except.png
I have added the wheel.jar file to the assets folder, and placed it on the build path. I've also checked wheel.jar in Order and Export. (This makes no sense to me, but I see this suggested in answer to similar questions.)
What have I done wrong, or failed to do?
Is there some reason why eclipse wouldn't just build a runnable project?
This is an update after trying the suggestion people have made. I still can't get it to work, so I'm afraid that I'm overlooking something so obvious that no one's thinking to tell me. Here is what I did.
I downloaded and unrarer a rar file with the wheel library and a wheel-demo project.
I created the wheel-demo project in eclipse, using new android project from existing cde.
I added a libs folder to my project, and copied wheel.jar into it.
I right-clicked on the wheel-demo project in Project Explorer, and chose java build path.
I clicked on "Add external jar" and navigated to wheel.jar.
I went to "Order and Export" and checked wheel.jar.
I had several errors. In the .java file for each activity (except the main activity), I got an error on the line
import kankan.wheel.R;
I commented this line out.
Also, since wheel.jar apparently doesn't specify a minimum API level, I got a error, but I just put a minimum sdk level of 8 in the manifest. I was then able to build the project without error. Still, the main screen comes up, but the app crashes as before when I press a button for any activity.
Can you see anything I've left out or done wrong?
Try to place your jar file to the 'libs' folder at the project root
I was never able to get it to work with the rar file. Here is what worked;
svn checkout http://android-wheel.googlecode.com/svn/trunk/ android-wheel-read-only
import wheel project into eclipse
fix the android:targetSdkVersion version in the manifest to get rid of the "unable to resolve target android-7" error
build the wheel project as a library
import wheel-demo project into eclipse
fix the skdVersion in the manifest
change "import android.wheel.R" to "import android.wheel.demo.R" in all the source files where it occurs.
build the wheel-demo project
I may have left out a minor detail or two.
I am baffled by eclipse. I had a working android application which i created inside eclipse. I now have come back to the application after a week and it is saying in the last java files there are hundreds of issue. I am sure there is no programming error inside the files as they worked one week ago. I think it may be a build path issue...i was wondering has anybody else come across this issue and why does it occur??
Several of my other projects also say the last file has errors which i know they dont.
Why is eclipse doing this to me?
Where should the build path point?
Under Java build path-> libraries..it says...unable to get system library for project?
Clean build in eclipse. That should generate the R.java and that should resolves your compilation issues.
This problem happens many times to me, here is the way I use to fix it:
Export the project to an external folder
Delete project from workspace (check "delete files on disk")
Import the project into the workspace again (check "copy project files to workspace")
Did you change the SDK location? That may cause this issue.
If possible please post exact error message.