Eclipse Export Signed Package 添加了两次可绘制目录,使 apk 大小加倍!

发布于 2024-11-09 17:17:59 字数 1040 浏览 2 评论 0原文

我从 2.1 左右就注意到了这一点。我相信问题出在 Eclipse Export to APK 插件或我的设置中的其他地方(尽管我不知道它可能在哪里)。

基本上,我的 APK 大小突然增加了一倍!一些调查显示 Eclipse 现在包含了可绘制目录(以及 raw、layout 和 xml 目录)两次。它一次将其包含在 res 子目录下,一次包含在应用程序的根目录下。

因此,不要有这样的目录结构:

- com
- META-INF
- res
  - drawable
  - layout
  - raw
  - xml
...

我有:

- com
- drawable
- layout
- META-INF
- raw
- res
  - drawable
  - layout
  - raw
  - xml
- values
- values-fr
- xml

还有其他人经历过这种情况吗?有谁知道为什么会这样?它将我的应用程序大小从 3mb 增加到了 6mb 以上,这是一个大问题。

我当前的解决方法是使用 eclipse 导出未签名的包,从根目录中删除可绘制、布局、原始和 xml 文件,然后手动对其进行签名并 zipalign。

如果您想查看该 apk,请查看此 apk(有问题)此 apk (我已手动修复)。两者都可以,其中一个只是两倍大。

我正在使用 Eclipse SDK,版本:3.5.2,构建 ID:M20100211-1343,Android 开发工具包版本:10.0.1.v201103111512-110841,尽管自从 2.1 发布以来,我在最后几个 ADT 中遇到了问题。我编译的 APK 级别似乎并不重要。

感谢您的帮助,见解!

I have noticed this since about 2.1. I believe the problem is in the Eclipse Export to APK plugin or else somewhere in my setup (though I have no idea where it could be).

Basically, all of a sudden my APK sizes doubled! Some investigating revealed that Eclipse was now including the drawable directory (and the raw, layout, and xml directories) twice. It includes it once under the res subdirectory and once under the root directory of the application.

So, instead of having a directory structure like:

- com
- META-INF
- res
  - drawable
  - layout
  - raw
  - xml
...

I have:

- com
- drawable
- layout
- META-INF
- raw
- res
  - drawable
  - layout
  - raw
  - xml
- values
- values-fr
- xml

Has anyone else experienced this? Does anyone know why this might be? It increased my app size from 3mb to over 6mb, which is a big deal.

My current workaround is to export an unsigned package with eclipse, remove the drawable, layout, raw, and xml files from the root directory, then manually sign it and zipalign it.

If you want to look at the apk, check out this apk (with the problem) and this apk (that I have fixed manually). Both work, one is just twice as big.

I am using Eclipse SDK, Version: 3.5.2, Build id: M20100211-1343, Android Development Toolkit Version: 10.0.1.v201103111512-110841, Though I have had the problem for the last couple of ADTs, since 2.1 came out. It doesn't seem to matter what APK level I compile for.

Thanks for any help, insight!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星光不落少年眉 2024-11-16 17:17:59

我终于解决了这个问题!

由于某种原因,我的 .classpath 文件中有一个错误,我自己从未编辑过这个文件,但在所有机器、Eclipse 版本和 SDK 版本之间的迁移中,它一定已经丢失了。

它显示:

    <?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="res"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

将其更改为:

    <?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

解决了问题。耶皮!

I have solved this finally!

For some reason, there was an error in my .classpath file, I have never edited this file myself but in all the migrations between machines, versions of eclipse, and versions of the SDK, it must have slipped it.

It read:

    <?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="res"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

Changing it to:

    <?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="src" path="gen"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
    <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
    <classpathentry kind="output" path="bin/classes"/>
</classpath>

Fixed the problem. Yippee!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文