Android Studio“无法解析符号R",但项目会编译并运行 [英] Android Studio “cannot resolve symbol R” but project compiles and runs
问题描述
Android Studio在所有Java文件中以红色显示:无法解析符号R",但项目可以编译并运行.
Android Studio displays in all java files in red : "cannot resolve symbol R" but the project compiles and runs.
我在这里尝试了所有解决方案: Android Studio无法解析符号"但是项目可以编译并正常运行,但是运气不好.
I have tried every solution here: Android Studio "cannot resolve symbol" but project compiles and works, but with no luck.
我试图:
-
使缓存无效并重新启动android studio
invalidate caches and restart android studio
删除.gradle和.idea文件夹
delete .gradle and .idea folders
清理并重建项目
安装新版本的android studio
install a new version of android studio
遇到gradle文件,然后撤消更改并同步项目
mess up with gradle file then undo changes and sync project
我想尝试的一件事,但我不知道如何实现,是在我第一次打开该项目时从头开始重新打开该项目,但我不知道如何执行此操作.
One thing that I want to try, but I don't know how to achieve, is to reopen the project from scratch as I was opening it for the first time, but I don't know how to do this.
我也从这里尝试了答案: Android Studio表示无法解析符号"但是项目可以编译, 但还是没有运气.
I also tried answers from here: Android Studio says "cannot resolve symbol" but project compiles, but again with no luck.
Android Studio版本= 3.2.1
Android studio version = 3.2.1
依赖版本:
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
classpath 'com.google.gms:google-services:4.0.0'
推荐答案
由于某些原因,我不明白,
For some reason that i do not understand ,
构建版本的这种组合导致了问题:
this combination of build versions made the issue :
grade version = 4.10.1
classpath 'com.android.tools.build:gradle:3.4.0-alpha01'
当我切换到这些构建版本时:
when i switched to these build versions :
grade version = 4.6
classpath 'com.android.tools.build:gradle:3.2.1'
问题已解决!
这篇关于Android Studio“无法解析符号R",但项目会编译并运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!