Android的工作室为何改变自R我提到的所有android.R?工作室、Android、android

2023-09-07 22:53:52 作者:一枕庭前雪

我在Android布局文件犯了一个错误(忘了 DP 在我的尺寸),并在重建,机器人工作室取代我的所有引用 R.java (因为错误的构建当中,并没有产生)与 android.R.java 。这是的正常的行为?我如何禁用此?这是造成允许自动进口?

I made an error in an Android layout file (forgot the dp in my dimension), and upon rebuilding, Android Studio replaced all of my references to R.java (which, because of the erroneous build, did not generate) with android.R.java. Is this normal behavior? How do I disable this? Is this caused by allowing auto-imports?

推荐答案

这是怎么回事的是,在你的XML文件中的错误是preventing项目的 R.java 从构建过程中所产生的,而IDE是看到,在code本研究引用现在可以明确地自动完成功能 android.R 和添加明确进口对飞的设置会前进,这样做。问题是, android.R 是错误的导入,当它真的应该等待 R.java 来解决。

What's happening is that the error in your XML file is preventing your project's R.java from being generated during the build, and the IDE is seeing that your R references in the code could now unambiguously autocomplete to android.R, and the Add unambiguous imports on the fly setting is going ahead and doing that. Problem is, android.R is the wrong import, when it really should wait for R.java to resolve.

如果你想离开添加明确进口对设置,请添加 android.R 飞在从导入排除和完成列表中的 preferences > 编辑> 自动导入,如下所示:

If you want to leave Add unambiguous imports on the fly set, please add android.R to the Exclude from Import and Completion list in Preferences > Editor > Auto Import as shown here:

 
精彩推荐
图片推荐