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
Related
For this particular project, Android studio just shows analyzing files, doesn't show any errors and the IntelliSense is also not auto-suggesting. I have tried to invalidate cache/ restart, checked that android studio is not in power mode, and also deleted the project locally and cloned it again, what can be the issue?
It was working fine till 2 days ago but today when I opened the app and tried to build it and make some changes to a few files, it just wont work.
I am on Android Studio 4.2.1 on macOS Big Sur 11.2.1
If I create a new project the studio is working fine but just for this project its not working
Here are the screenshots
Any help is much appreciated! Thanks!!
I have posted the same answer in another post, you can take the reference from the below link.
https://stackoverflow.com/a/67984260/11414681
You just need to Upgrade the latest kotlin version.
Upgrade the dependency in the project's build.gradle file.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
Upgrade the dependency in the app's build.gradle file.
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.10"
Delete .idea , .gradle andr buid folder from your project path.
After delete your project from Android Studio and re-open and its work.
Sometimes android studio has been not working properly so ignore this bugs its nothing.
Just make File -> Invalidate caches and restart
Check my answer here, stackoverflow.com/a/68755611/2281717
In my case, I just update all dependencies on my Android App Project. And it's working
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.
I upgraded the studio to 3.1.2 version lately. After that facing few issues, one of which is this :
Even though all imports are written correctly, the files are said not to be found and I get the class names in red saying "Cannot resolve symbol".
But when I try to run the project it runs perfectly. I tried to invalidate cache and restart, clean project, rebuild project, also tried restarting the PC but no solution.
You have to update your Kotlin library version and check some other version of library it might be not compatible with new android studio version and also check gradle version.
I recently installed Android Studio on my Desktop running Ubuntu 17.10. However, when I open any Android Studio Project or even create a new Project, while editing XML files, it wrongly displays an "unknown attribute" error. Normally, I wouldn't care, but this causes Android Studio to not give any suggestions for attributes which I need.
What I've tried:
Invalidating cache
Deleting the .iml file and rebuilding project
Rebuilding and cleaning project several times
Deleting gradle's cache
Updating Android Studio (Current Release is Android Studio 3.1)
Here is a screenshot of what's happening
Try doing a gradle sync. It should resolve the problem
I´ve tryed all the solutions but the only thing that worked for me was 4gus71n's answer.
Deleting the C:\Users.AndroidStudio3.2\system\caches folder solved my problem.
Link to his answer: https://stackoverflow.com/a/53160674/6568421
Use project's SDK not Android's SDK. You can edit SDK Location in local.properties file
I had faced similar issues and all the above also did not worked for me.
If all else failed, do a clean install of android studio. You need to do a clean installation because if you just uninstall and install again, some of the files still remains in your system. It did not work for me when i just uninstall and install android studio. The clean install worked for me and I believe it should solve most of the problems.
I faced this error probably because i installed an entire android project but I am not very sure what is the exact error that caused this problem.
For clean installation, you can look at this links for windows and mac
How to completely uninstall Android Studio from windows(v10)?
How to completely uninstall Android Studio on Mac?
I'm struggling with a Gradle: : java.lang.NullPointerException message each time I restart Android Studio. The solution is to remove all facets from the Modules section, add them once again and rebuild the project. The problem is I have to do this each time I launch Android Studio along with my project. How do I solve this problem?
The project was imported from an Eclipse project, and Gradle is configured probably fine (I'm using a local distribution and have set path to its directory).
Other questions did not seem to address the reoccurence of this problem.
Android Studio is an early access preview, and bugs are to be expected. Best chance to solve the problem is to file an issue with an exact description.