Java build文件夹下的文件是生成的,不能编辑,不能重新build android工程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28389276/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Files under the build folder are generated and should not be edited, cannot re-build android project
提问by
I was programming an Android application when suddenly it was unable to resolve symbol R in my MainActivity. I have had this issue before and it is usually fixed by going to tools->android->syncProjectWithGradleFiles but this did not work. Instead when I attempt to do this it takes me to my AndroidManifest.xml file and gives me the message: "Files under the build folder are generated and should not be edited" shown belowFurthermore, these errors are displayed below:
我正在编写一个 Android 应用程序时突然无法解析我的 MainActivity 中的符号 R。我以前遇到过这个问题,通常通过转到 tools->android->syncProjectWithGradleFiles 来解决,但这不起作用。相反,当我尝试执行此操作时,它会将我带到我的 AndroidManifest.xml 文件并给我消息:“生成文件夹下的文件已生成,不应编辑”如下所示此外,这些错误显示如下:
These errors specify that: No resource found that matches the given name (at 'icon' with value '@drawable/icon'). which is part of a service I recently tried to add. So I tried deleting the service text here; however whenever I delete the service text, it keeps being re-added to the .xml file whenever I attempt to sync the projects with gradle files again. I have re-built the project and cleaned the project both returning the same errors... Can anyone help me fix this?
这些错误说明: 找不到与给定名称匹配的资源(在值为 '@drawable/icon' 的 'icon' 处)。这是我最近尝试添加的服务的一部分。所以我尝试在这里删除服务文本;但是,每当我删除服务文本时,只要我尝试再次将项目与 gradle 文件同步,它就会不断地重新添加到 .xml 文件中。我重新构建了项目并清理了项目,都返回了相同的错误......谁能帮我解决这个问题?
采纳答案by tsil
This is because you are trying to modify the wrong versionof AndroidManifest. Android Studio shows you the file located in the build folder when it finds errors. Open app/src/main/AndroidManifest.xml and modify it.
这是因为您试图修改错误版本的 AndroidManifest。当 Android Studio 发现错误时,它会向您显示位于 build 文件夹中的文件。打开 app/src/main/AndroidManifest.xml 并修改。
回答by Dráusio Fonseca Tronolone
This usually happens when you have filenames that are not accepted by Studio. For example, a file named 001.jpg will throw that error because files cannot start with numbers. Check if you renamed some file that once belonged to Build and check all the files you added.
当您的文件名不被 Studio 接受时,通常会发生这种情况。例如,名为 001.jpg 的文件将抛出该错误,因为文件不能以数字开头。检查您是否重命名了一些曾经属于 Build 的文件并检查您添加的所有文件。
回答by yshahak
I had encounter this when I putted 0 value in the screenOrientation attribute and it solved just after I deleted the file in the path
当我在 screenOrientation 属性中放置 0 值时遇到了这个问题,并且在我删除路径中的文件后它就解决了
...path_to_modoule\app\build\intermediates\manifests\full\debug.AndroidManifest.xml
回答by numan ghuffar
Just remove the affected code and clean the project one or two times and restart Android Studio. It works for me.
只需删除受影响的代码并清理项目一两次,然后重新启动 Android Studio。这个对我有用。
回答by Alex Burdusel
I got this error after probably deleting by mistake some files from the SDK. I removed Android SDK Build Tools and reinstalled them and the problem was gone
我可能错误地从 SDK 中删除了一些文件后收到此错误。我删除了 Android SDK Build Tools 并重新安装了它们,问题就消失了
回答by r mvivek android developer
i was solving this problem
step 1:
我正在解决这个问题
第 1 步:
First remove a android:icon="@drawable/ic_app" and android:roundIcon="@drawable/ic_app" .
首先删除 android:icon="@drawable/ic_app" 和 android:roundIcon="@drawable/ic_app" 。
step 2:
第2步:
edit or add android:icon="@drawable/ic_app"
编辑或添加 android:icon="@drawable/ic_app"
回答by Israel Agostinho
I had the same problem. I only closed AndroidManifest and opened it again and so I edited acording to which the error log showed. This problem happens because (for some reason) you have debug/AndroidManifest.xml opened instead of main/AndroidManifest.xml. Just close the debug one and open the main one.
我有同样的问题。我只关闭了 AndroidManifest 并再次打开它,因此我根据错误日志显示的内容进行了编辑。发生此问题是因为(出于某种原因)您打开了 debug/AndroidManifest.xml 而不是 main/AndroidManifest.xml。只需关闭调试器并打开主器即可。