cannot find symbol class R android studio 3.0.1 - android

cannot find symbol class R
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.

I think the project xml design contains any error. in that case R file could not be created. So please verify the xml file if no such error found then rebuild the project using Build → Clean Project / Rebuild Project

Check if there are any errors in your build.gradle (Module: app) file, and then sync it by using the refresh button from the Gradle panel.
Build > Clean Project, and then Build > Rebuild Project
I have been using MacBook Pro for my Android development, but I don't shut down but use the sleep mode normally. Because of this, my Android Studio gets out of control occasionally. Therefore, by simply restarting your entire development PC might resolve your issue.
Alternatively, you can try File > Invalidate Caches/Restart to clean up all the related caches.

Make sure that you have imported import <package_name>.R; (you can use Alt + Enter), than clean and rebuild your project (Build → Clean Project / Rebuild Project)
Note: Sometimes importing R file could not resolve the issue

Related

Execution failed for task ':shared:podInstall'

I am very new to KMM (Kotlin Multiplatform Mobile) and iOS development (including CocoaPods). I have come across the following build error in Android Studio.
Execution failed for task ':shared:podInstall'.
java.io.IOException: Cannot run program "pod" (in directory "/Users/.../AndroidStudioProjects/.../iosApp"): error=2, No such file or directory
The directory definitely exists and I seem to be able to manually run pod commands from within the directory. I am not sure but it seems like this problem came about when I updated the Kotlin plugin from 1.5.0 to 1.5.10. This problem occurred even when starting a completely new KMM project.
I thought it might have something to do with Android Studio not being able to find the pod command so I added it to the path but that didn't seem to do anything. Any help with this would be appreciated.
Check your Gradle JDK :
Android Studio > Preferences > Build, Execution, Deployment > Build Tools > Gradle
Then select Gradle JDK -> Embedded JDK
Maybe you must execute in command line :
./gradlew :shared:podInstall
Have you tried File > Invalidate Cache and Restart?
I had exactly same issue, but It got fixed after invalidate cache and restart.

Can't build my android project after move it to another computer

I can't build my android project in react native project, i just used this project in my old computer and it built fine, but after i clone it from my new macbook i get error.
I tried to delete the cache folder and it didn't help.
The error that i get:
FAILURE: Build failed with an exception.
What went wrong:
Could not open settings remapped class cache for espedq8f7vbnwrshulq11juyl (/Users/(UserName)/.gradle/caches/5.0/scripts-remapped/settings_3tlaqtt0fziq08p73u9gmyutn/espedq8f7vbnwrshulq11juyl/settingsa9190c3ddc71e1450eb3f3e7bc6a334f).
Could not open settings generic class cache for settings file '/Users/(UserName)/Desktop/MyApp/friendsapp/client/android/settings.gradl' (/Users/(UserName)/.gradle/caches/5.0/scripts/espedq8f7vbnwrshulq11juyl/settings/settingsa9190c3ddc71e1450eb3f3e7bc6a334f).
BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 57
Yes i found the answer!
I just clicked in android studio, FILE -> sync project with gradle files .
It did the magic !
Edit
Help me so many times for building:
yarn add jetifier
yarn run jetify
rebuild project in android studio
To clear Android Studio's cache and bring it out of its state of confusion, select 'File > Invalidate Caches / Restart' and then click the 'Invalidate and Restart' button.
You should invalidate caches from android studio not deleting cache folder directly.

Gradle project sync failed (Android Studio)

I have an error everytime I switch from one branch to another in my project (so I have to do 'Invalidate cache and restart', it helps, but takes time and it's not normal to do it everytime):
Gradle project sync failed. Basic functionality will not work
properly.
It started after I updated gradle and Android Studio. Now in my 'Project Structure' -> 'Project' I have Gradle version 3.3 and Android Plugin Version 2.3.0. The same is in other my branch. Any advice what is wrong?
Make sure that both run in the same versions and try again.
Try these two tasks:
1)Go to File>>Other Settings>>Default Porject Structure. Check there
the jdk path. Make sure that you have 64_bit.Finally, after this
clean project and rebuild it.
2.Go to the directory \Users\user.gradle\caches\2.x. You will find the directories
scripts & scripts-remapped. Keep a backup of them and then delete
them from the directory.Retry gradle sync. It should work as it will
generated new cache files
Found the solution: just click Tools > Android > Sync Project with Gradle Files (did it in every branch). Everything is fine now. Thanks to this article: http://devdeeds.com/update-gradle-plugin-android-studio/
My solution is :
File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Now try to import that project using another project
Gradle build success !!
Done.
Hope it helps.

R java File missing

I recently added "recyclerview" dependency in my project and synced it.After syncing i found my R.java file missing. Now android is not showing support for R statements in the project.Please tell me how to fix this.
Sometimes, do a "clean" on your project will also fix this.
Eclipse: Project -> Clean, then rebuild your project
Android Studio: Build-> Clean, then Build -> Rebuild Project
Well Relax here is a Trick
Comment Every-line in .java File where your Using R reference,then Build your Project,It Will Rebuild R File,Now Uncomment then and you're good to go
i just copies the R file from another project.

android studio new project cannot find symbol 'R'

I just made a clean android studio project and I'm getting errors in my Main file saying R isn't found. I know it's not an xml error since it's a new project...I've tried to sync project with gradle files but that doesn't seem to do anything. It just comes back with an :app:mergeDebugResources error..
Select Build > Clean Project
It should rebuild and recreate the R file :-)

Categories

Resources