【问题标题】:deleted gen folder, eclipse isn't generating it now :(删除了 gen 文件夹,eclipse 现在没有生成它:(
【发布时间】:2011-09-15 01:21:59
【问题描述】:

我不小心删除了我的 gen 文件夹,现在,可以预见的是,我的资源都被搞砸了。我刚刚自己创建了一个 gen 文件夹并尝试 project > clean - 那没有用。尝试右键单击项目并转到 android 工具 > 修复项目属性 - 没有用。尝试自动取消选中构建...没有用。清理,关闭项目,关闭 Eclipse,重新启动等。没有任何工作,我一直看到这个错误:gen already exists but is not a source folder. Convert to a source folder or rename it.

编辑 - OK 能够生成 R.java,但现在我在控制台中得到了疯狂的东西:

[2011-06-14 17:06:11 - fastapp] 转换为 Dalvik 格式失败 有错误 1 [2011-06-14 17:06:42-fastapp] Dx 处理“java/awt/font/NumericShaper.class”时遇到问题:

Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.

This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.

However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.

If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.

If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.

If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.

[2011-06-14 17:06:42 - fastapp] Dx 1 error; aborting
[2011-06-14 17:06:42 - fastapp] Conversion to Dalvik format failed with error 1

而且eclipse无法解析我的资源import com.me.fastapp.R;的导入

【问题讨论】:

标签: android eclipse


【解决方案1】:
  1. 右键单击您的项目
  2. 选择属性。
  3. 选择 Java 构建路径
  4. 点击添加文件夹
  5. 选择gen文件夹
  6. 点击确定。

【讨论】:

  • 太棒了!这似乎将 gen 文件夹放在需要的位置,但没有生成 R.java...
  • 您可能还需要重建项目。如果您使用默认设置,它会自动构建,因此请清理项目。转到项目菜单,选择清理,选择所有项目(或任何您的问题项目)。
  • 看来我现在明白了。谢谢!
  • 我遇到了同样的问题,但即使再次清理后仍然没有生成 R.java ...请帮助 ...
  • 我遇到了同样的问题。在遵循@kabuko 的建议之后,我必须在代码编译之前删除eclipse 决定为我添加的import android.R;。希望有帮助
【解决方案2】:

我不知道这是否有资格作为答案,但我最终举起双手,只是恢复到我的最后一次提交。

【讨论】:

    【解决方案3】:

    在将我的 SDK 升级到 v22 并将 ADT 升级到较新版本后,我今天遇到了同样的问题。显然我的 SDK 管理器没有检测到 SDK Platform-Tools 和新引入的 SDK Build-tools 也发生了变化,因此它没有升级工具,导致我的 SDK/ADT 包不生成 /gen 文件夹的内容日食。

    升级 SDK 和 ADT 后,我必须返回 SDK 管理器,这样我就可以选择将 SDK Platform-tools 安装/更新到 17(我有 16 个)和 SDK Build-tools(也是 17 个) .

    【讨论】:

      【解决方案4】:

      R 类的准备可能存在问题(例如,由于某些布局 xml 中的错误)。从 Preferences 将构建器输出设置为“verbose”,然后在控制台中查看生成中断的位置。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-05-22
        • 1970-01-01
        • 2016-10-13
        • 1970-01-01
        • 1970-01-01
        • 2013-11-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多