Android的工作室 - “无法解析符号”语法高亮显示的错误,虽然建设是确定 [英] Android Studio - 'Cannot resolve symbol' syntax highlighting errors although build is ok
问题描述
我有一个非常恼人的问题,因为几天后,我试图恢复previously工作的Android Studio项目从备份中,得到一个新的计算机后。
I have a really annoying problem since several days, after I tried to restore a previously working Android Studio project from a backup, after getting a new computer.
我在无法解析符号语法高亮的问题,从机器人库中的类,如 android.support.v7.app </ code>,
android.support.v4.app </ code>,和谷歌播放服务,这是我列为依赖关系。
但是,该项目构建罚款,我可以在手机上没有问题运行的应用程序。
I have the "cannot resolve symbol" syntax highlighting problem with the classes from Android libraries such as android.support.v7.app
, android.support.v4.app
, and Google Play Services, which I have included as dependencies.
But, the project builds fine and I can run the App on phone with no problems.
我已经验证SDK安装目录下是否存在这些JAR文件 - 用于如\ SDK \演员\机器人\ m2repository \ COM \机器人\ SUPPORT \ appcompat-V7 \ 23.0.1。
I have verified whether these jar files exist under SDK installation - for e.g. "\sdk\extras\android\m2repository\com\android\support\appcompat-v7\23.0.1".
我的问题是非常相似,报道在下面的帖子中的:
My problem is quite similar to the ones reported in below posts:
- <一个href="http://stackoverflow.com/questions/19508649/android-studio-says-cannot-resolve-symbol-but-project-compiles">Android工作室说&QUOT;不能解析符号&QUOT;但项目编译
- <一个href="http://stackoverflow.com/questions/18991161/android-studio-cannot-resolve-symbol-but-$c$c-executes-correctly?lq=1">Android Studio无法解析符号,但code正确执行
- <一个href="http://stackoverflow.com/questions/21100688/android-studio-suddenly-cannot-resolve-symbols?lq=1">Android工作室突然不能解析符号
- Android Studio says "cannot resolve symbol" but project compiles
- Android Studio cannot resolve symbol but code executes correctly
- Android Studio suddenly cannot resolve symbols
我已经尝试了所有在各种计算器的讨论(即同步摇篮工程,无效高速缓存/重新启动,清理/重建提供的解决方案,删除摇篮生成的文件(.gradle,建设,.idea目录等),降级至较低的空气污染和升级等,但没有一种方法是有帮助的。
I have tried all the solutions provided in various stackoverflow discussions (i.e. Sync Gradle Project, Invalidate Cache/Restart, Clean/Rebuild, Deleting gradle generated files (.gradle, build, .idea directories etc.), downgrade to lower API and upgrade etc. But, no method is helpful.
我采用Android 1.3.2工作室和API 23.所有构建工具,支持库等,是最新的(试图与这两个V22 +和V23 +的库)。
I use Android Studio 1.3.2 and API 23. All build tools, support library etc. are up to date (tried with both v22.+ and v23.+ of the libraries).
请做帮助,如果你有什么其他的建议!
Please do help if you have any other suggestions!
这是我build.gradle摘录:
Extract from my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '23.0.1'
defaultConfig {
applicationId "com.myapp.fun"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:22.+'
compile 'com.android.support:appcompat-v7:22.+'
}
问题截图也可以在下面找到。我认为Android Studio是无法导入的语法高亮的依赖库,但是编译器能够将它们包括和构建成功。
Screenshots of the problems can also be found below. I think Android Studio is not able to import the dependent libraries for syntax highlighting, although the compiler is able to include them and build successfully.
推荐答案
的原因是因为我有一个'!在我的项目路径符号。 很显然,我现在了解到,许多Java程序这个原因失败的原因! :-)
The reason is because I had a '!' symbol in my project path. Apparently, as I learnt now, many Java programs fail due to this reason! :-)
我刚刚更名的道路,它现在工作得很好:-)
I just renamed the path and it works fine now :-)
P.S。
感谢您@加布里埃尔 - 马里奥蒂为 gradlew干净
的建议。事实上,这帮助我找到真正的根源。我无法从终端执行 gradlew
由于的RuntimeException
:
Thank you @gabriele-mariotti for the gradlew clean
suggestion. In fact, that helped me find the real root cause. I was not able to run gradlew
from the terminal due to a RuntimeException
:
Could not determine wrapper version. at org.gradle.wrapper.GradleWrapperMain.wrapperVersion
但是,这帮助我学习的效果'!符号上的路径,以及对问题的根本原因。谢谢大家!
But that helped me learn about the effect of '!' symbol on paths, and to the root cause of the problem. Thank you all!
这篇关于Android的工作室 - “无法解析符号”语法高亮显示的错误,虽然建设是确定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!