【问题标题】:Why does building a release APK fail only when android:debuggable="false" is set?为什么只有在设置 android:debuggable="false" 时构建发布 APK 才会失败?
【发布时间】:2013-12-06 00:18:09
【问题描述】:

最近,Google Play 商店似乎强制要求所有上传的应用程序必须在 AndroidManifest.xml 文件中设置 android:debuggable="false"。我之前设置了android:debuggable="true"

但是,当我设置android:debuggable="false" 时,我的ant clean release-obfuscate: 步骤中爆炸。

ProGuard 似乎是罪魁祸首:

/usr/local/Cellar/android-sdk/r21.1/tools/ant/build.xml:875: Can't write [/Users/-/Code/android/bin/proguard/obfuscated.jar] (Can't read [/Users/-/Code/android/libs/android-async-http-1.4.3-no-redirect.jar] (Duplicate zip entry [com/a/a/a/b.class == android-async-http-1.4.3-no-redirect.jar:com/loopj/android/http/AsyncHttpClient$1.class]))

关于如何进行的任何指导?使用android:debuggable="true" 进行发布构建与使用android:debuggable="false" 进行发布构建时,混淆步骤有何变化?

一些额外的细节:

  • 做一个标准ant clean release
  • 项目实际上是用 Scala 编写的
  • 使用 17 级构建工具
  • ProGuard 4.4

【问题讨论】:

  • 你确定是设置 android:debuggable 导致的问题吗?请注意,默认值为 false,因此您可以将其删除并尝试重新构建。
  • 奇怪的是——我确实是。它在 android:debuggable="true" 时发布版本有效,当我删除该属性或将其设置为 android:debuggable="false" 时它会失败

标签: android scala ant proguard


【解决方案1】:

原来我在proguard-project.txt 中包含了一些第三方库,如下所示:

-injar "libs/android-async-http-1.4.3-no-redirect.jar"

我删除了所有 -injar 库,并将我的 ant build.xml 中的 proguard post-compile 步骤替换为 debug-obfuscation-check 任务:

<target name="-debug-obfuscation-check">
 <property name="proguard.enabled" value="true" />
 <path id="out.dex.jar.input.ref" />
</target>

仍然不确定发生了什么。显然,在 proguard 中使用 -injars 库是一种非常糟糕的做法(根据 ProGuard 手册)。我将其他一切都归咎于将 scala 用于 android 项目的麻烦。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-24
    • 2019-06-18
    • 1970-01-01
    • 2021-06-29
    • 2018-01-18
    • 1970-01-01
    • 2015-04-05
    相关资源
    最近更新 更多