Java 存在不同大小写的资源,并且未生成类文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24870358/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 15:18:49  来源:igfitidea点击:

A resource exists with a different case, and class files not generating

javaandroideclipsemanifest

提问by steff_bdh

Getting a problem in eclipse which says

在 eclipse 中遇到一个问题,上面写着

The project was not built due to "A resource exists with a different case: 
'/AgriExpenseTT/bin/classes/uwi/dcit/agriexpensett'.". Fix the problem, then try           refreshing this project and building it since it may be inconsistent

I've read other posts saying to check my package name/ delete my R.java/ delete bin folder/clean the project/restart eclipse and or computer, i've tried them all but to no avail, however i've noticed that in my bin/classes/uwi/dcit/agriexpensettthere were no class files, is that supposed to happen if i've an error, any help is appreciated thanks

我读过其他帖子说要检查我的包名称/删除我的 R.java/删除 bin 文件夹/清理项目/重新启动 eclipse 和/或计算机,我已经尝试了所有但无济于事,但是我注意到在我的bin/classes/uwi/dcit/agriexpenset中没有类文件,如果我有错误,是否应该发生这种情况,感谢任何帮助

回答by Abeer Sul

This problem is caused by a typo in your package name some where in the project, "a different case".

这个问题是由你的包名在项目中的某个地方打错字引起的,“不同的情况”。

I suggest you compare package name in all these places:

我建议你在所有这些地方比较包名:

1.Manifest.xml >> package name should be all in small letters

1.Manifest.xml >> 包名要全小写

2.packages in src folder

2.src文件夹中的packages

3.packages in gen folder

3. gen 文件夹中的包

they should all be the same, if not fix it or refactor the wrong package name, this will solve it.

它们应该都是一样的,如果不修复它或重构错误的包名称,这将解决它。

my problem was in different case in gen folder package, i hope this helps.

我的问题是在 gen 文件夹包中的不同情况,我希望这会有所帮助。

*keep on cleaning, building the projects, closing/reopen them and restarting eclipse sometimes

*继续清理,构建项目,关闭/重新打开它们并有时重新启动eclipse

回答by Amit

Faced this problem just now and found the cause. My source code was under the package com.ABCD.util and test code in com.ABCD.util.test. Then I changed the source code package name from com.ABCD.util to com.abcd.util. After that I started getting this error. Test classes which were going to the same bin folder, differed in case (ABCD and abcd). Once I changed the case of test-classes too, the problem went away. All his, even though the package ABCD was empty.

刚刚遇到这个问题,找到原因了。我的源代码在 com.ABCD.util 包下,测试代码在 com.ABCD.util.test 下。然后我将源代码包名称从 com.ABCD.util 更改为 com.abcd.util。之后,我开始收到此错误。进入同一个 bin 文件夹的测试类,大小写不同(ABCD 和 abcd)。一旦我也改变了测试类的情况,问题就消失了。所有他的,即使包裹 ABCD 是空的。

回答by Hasson

The best way I found to avoid this problem is to make an intermediate change to another package name, so if you are trying to rename a package from com.example.MyApplicationto com.example.myapplicationyou need to do the following:

我发现避免此问题的最佳方法是对另一个包名称进行中间更改,因此如果您尝试将包重命名com.example.MyApplicationcom.example.myapplication,则需要执行以下操作:

  1. Rename the package com.example.MyApplicationto com.example.myapplication2(this should be successful and you will not face the error: [A resource exists with a different case ..]

  2. Rename the package com.example.myapplication2to com.example.myapplication

  1. 将包重命名com.example.MyApplicationcom.example.myapplication2(这应该是成功的,您不会遇到错误:[A resource exists with a different case ..]

  2. 将包重命名com.example.myapplication2com.example.myapplication

This way I could avoid this error in Eclips, I think it is related to the fact that package names has to be reflected to the folder names in the file system, so you can not have two folders with the same name but different with the case only.

这样我就可以在 Eclips 中避免这个错误,我认为这与包名称必须反映到文件系统中的文件夹名称这一事实有关,因此您不能有两个名称相同但大小写不同的文件夹只要。