简体   繁体   English

Android Studio kotlin文件显示为来自不同包和XML文件的R类

[英]Android studio kotlin files show as R class from different packages and XML files

This is not my project but the code runs fine. 这不是我的项目,但是代码运行良好。 Some kotlin files show up as either R class from some random package or as XML files and have different icons. 一些kotlin文件显示为来自某些随机包的R类,或者显示为XML文件,并具有不同的图标。 Files that show correctly have errors like Unresolved reference pointing to the files that don't show correctly but it still compiles and runs. 正确显示的文件会出现错误,例如未解析的引用指向无法正确显示的文件,但仍可以编译并运行。

Android studio 3.2.1 Android Studio 3.2.1

Gradle 4.6 摇篮4.6

Kotlin plugin 1.2.51 and 1.2.71 Kotlin插件1.2.51和1.2.71 在此处输入图片说明

Try these: 试试这些:

  1. build -> clean project, build project 建立->清理项目,建立项目
  2. file -> sync project with Gradle files 文件->使用Gradle文件同步项目
  3. file -> invalidate and restart 文件->使无效并重新启动

The fix to this is to open and save the file in question with a text editor like sublime text or notepad. 解决此问题的方法是使用文本编辑器(如sublime文本或记事本)打开并保存相关文件。 I'm not sure if this is a bug with android studio or what but I can't submit a bug either way since I doubt this is reproducible. 我不确定这是否是android studio的错误还是什么,但是我不能以任何方式提交错误,因为我怀疑这是可重复的。 If anyone else is experiencing this, I hope this workaround works for you and thanks for everyone who helped, have a good day. 如果有其他人遇到这种情况,我希望此解决方法对您有用,并感谢所有帮助您,度过愉快一天的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM