I got weird issue after upgrade to Android Studio 3.2
The project is built successfully, the app is running but R class stays in red and its not allowing me to do Ctrl + Click to go to definition.
I've already tried Clean Caches and Restart, Clean project, Rebuild project, delete build folder.
Answer
After some time, I've download Android Studio 3.3 Canary 13 from https://developer.android.com/studio/archive and it works now.
Go to your AndroidManifest.xml folder and fix any problenms you may have there ( check the other xml folders just in case). Then clean the project, rebuild and sync project with gradle. My app wasn't running because it was unable to resolve R. Tried all the methods you tried first but the problem for me was in the AndroidManifest.xml. Hope this is the solution to your problem.
Related
from a week I was updated my Android Studio version to stable version 4.0.0 then I am started getting this errors in my studio and unable to build the app.
Unable to save plugin settings: The plugin org.jetbrains.android failed to save settings and has been disabled. Please restart Android Studio
But I forcefully enabled all plugins in my Studio by going to File-->Settings-->Plugins --> All are enabled.
Select Embedded JDK in Android Studio
Try that:
delete the .idea folder in the android project folder where you faced this problem.
Close Android Studio. Now navigate to your projects .idea folder and rename the workspace.xml file to workspace-o.xml and delete a workspace.xml~ if it exists (i.e., AS has a corrupt workspace layout file).
This should fix the problem. Restart AS and configure the workspace back they way you like it (i.e., it will start with a simple view: View/Tools Windows/Project etc.).
I started my first project in Android Studio and my answer may not be the correct one. I ran into this problem during building the My Activity project. It always came back with this error asking me to restart. Finally I thought that the controlled folder file access is preventing me. I temporarily switched-off the protection(against Ransomware in Windows 10) and tried the Build. I stopped getting these messages. But, I have other problems I am looking into.
I deleted the .idea folder and then I invalidated the cache (file-> invalidate Cache/Restart)
This fixed my issue.
I am using Android Studio 3.2.1. This error, where the R class is highlighted in red, says Cannot Resolve R, but the app builds and runs just fine, there are no errors in compilation, it just shows R as unresolved reference in the IDE.
This problem only happens in one project that uses Kotlin, and all the other projects open and work without any problems.
I went through most solutions in stackoverflow and that didn't solve the problem.
I'm using ubuntu and it works on other windows pc. Could there be a problem in ubuntu.
These are the solutions that I have tried
clean project
rebuild project
make project
invalidate cache and restart
sync project with gradle files
updating sdk files
updating dependency
recloning the project
checked all my xml files
Kotlin plugin was updated
snapshot
xml snapshot
The issue still persists. Please let me know if any other details are required.
Thanks.
Just try reinstalling it
Hope it works :)
this problem with the android studio itself try to clear cache and restart from file --> invalidate the cache and restart if still not working reinstall the android studio and open the project from the beginning
First, I really dont know wth goin on with android studio ver 3.2.1. I got too much bullshit errors after update this version. Funny thing is i do nothing. After update, everything is fine, but when i restart IDE. everything go wrong.
I tried clear caches, re-install Android Studio, Invalidate Caches, Re-sync project with Gradle, clean project, re-build project. But, nothing change. So, i hope someone can help me. Thanks so much!
Try these:
Method 1:
Delete the .idea folder that is in the project location
Build > Clean Project
Then change something in the app level gradle
Then android studio will ask you to sync the project. Go ahead and sync, the problem will be gone
Credits: https://stackoverflow.com/a/47825463/10471480
Method 2:
Try cleaning up of the following folders:
c:\Users\<user>\.gradle\caches\
c:\Users\<user>\.AndroidStudio3.2\system\caches\
100% Working
Do this two steps:
1.Go to folder where you android studio caches are located. I have android studio 3.6.3 For me it's "C:\Users\Lenovo.AndroidStudio3.6\system\caches"
2.Go to the folder where you android studio projects are located. Open the project >then .idea folder and delete the caches. For me its "C:\Users\Lenovo\AndroidStudioProjects\MyDictionary.idea\caches"
When I started up my project this morning it randomly gave me a message saying Gradle project sync failed. Basic Functionality(eg. editing, debugging) will not work properly. in Android Studio. I looked at other answers that people had put up for this problem but they haven't been working. I invalidated my chaches/restarted my project but no luck. I also deleted my .gradle folder from my project folder and still no luck. If any of you guys could help me that would be awesome! This didn't happen yesterday when I was working on the project or anything, I wonder why its happening now. Oh yea it also says this as a gradle message: Error:C:\Users\Dave\.gradle\caches\2.2.1\scripts\settings_ad4t0wp5ikihzl1y1o83b5sbw\SettingsScript\buildscript\cache.properties (The system cannot find the file specified) :
Thanks again for anyone who reads this/ can help!
There is a file - "cache.properties" that gradle creates for you, upon first time inception of any project. The path for this file is "~Home_Directory\.gradle\2.2.1\taskArtifacts". You may find this path in your home directory. So basically, this file - "cache.properties" is missing from the "taskArtifacts" folder.
One of the solution that worked for me is to copy file - "cache.properties" from any test project of yours to this project that's currently experiencing an issue.
Regards
I had to choose using the Default Gradle Wrapper instead of local.
<< SETTINGS -->/ BUILD TOOLS --> Gradle --> radio button switch... >>
It has helped me to fix the same problem.
I had experience similar sync failed problem with gradle based android project (in Android Studio 1.1.0). I solved this problem without deleting .gradle from my user directory,
steps I followed was
Go to File -> Settings -> Compiler(Gradle Based Android Project)
Change VM options to -Xmx512m -XX:MaxPermSize=512m.
Click Apply -> OK and then tap on Try Again option in sync failed message to clean build the project.
Works like charm!!
UPDATE - 1 : For Android Studio 1.3, Compiler option mentioned in above Step-1 is present inside tab Build, Execution, Deployment.
I had faced similar kind of problem earlier!
But don`t know after rebuild the project and cleaning it, it worked normally.
Invalidate dependency cache by running
gradle clean build --refresh-dependencies
from project root and then re-import your project. Worked for me once.
May be you have put Android Studio into offline mode. To fix it, go to Preferences -> Gradle and ensure that the "Offline work" checkbox is not checked.
Than do
File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Restart Android Studio let it download all the Gradle stuff it needs
android studio 0.4.2: Gradle project sync failed error
Delete the folder C:\Users\.gradle and reopening the android studio solved my problem
i am using android studio 0.9.2. I copied project folder(all folders projectname->.gradle,.idea,app,build,gradle and all files placed in this level) and renamed it and then in android studio i goto FILE-> CLOSE which close current opened project. Now i open again the project which i have copied. When i make some changes in code its not effecting compiler or debugger. I have debugged my code and found that my change in code does not take affect.
I have tried FILE->INVALIDATE CACHE AND RESTART and then check again but no luck. I have also closed my android studio and run it again but still i am facing same issue
I think its compiling old project which is last opened project.
Any help will be highly appreciated?
Try cleaning the project. There are three ways to achieve that:
via Menu: Build -> Clean Project
via gradle run gradlew clean
delete all the build directories in your project/modules
After that compile your project again (e.g. with the green play button) and you should be done.
I have a question. Is your gradle setting is in offline mode? Try turning it to online mode.
Also, just to add to above answer, Do you have any gradle dependencies with other project?
If so, also try cleaning those archives from your project folder within .m2 (maven) folder.