android-maven-plugin:禁用 apk 的调试构建 [英] android-maven-plugin: Disable debug build for apk

查看:37
本文介绍了android-maven-plugin:禁用 apk 的调试构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不清楚在使用 android-maven-plugin 构建时禁用调试构建的确切程序:

I am not clear about the exact procedure for disabling debug build while building with android-maven-plugin:

我知道带有 ADT(21.1) 的导出向导会自动禁用调试,但它被破坏了,因为 BuildConfig.DEBUG 总是返回 true 并且我的日志记录过去依赖于它.(现在我在我的 Maven 构建配置文件中定义了自己的日志记录属性.)

I understand that the export wizard with ADT(21.1) will automatically disable debugging but it is broken as BuildConfig.DEBUG always returns true and my logging used to depend on it. (Now I have my own property for logging defined in my maven build profiles.)

因此,如果我必须使用 android-maven-plugin 禁用调试,那么正确的方法是什么?

So if I have to disable debugging using android-maven-plugin, what is the the right way to do it?

我使用以下插件:

  1. maven-编译器插件
  2. maven-jarsigner-plugin
  3. proguard-maven-plugin
  4. 带有 zipalign 目标和配置的 android-maven-plugin.

我不确定签名和 zipaligning 是否会自动禁用调试,因为我在 Maven 输出中看到以下行:

I am not sure whether signing and zipaligning automatically disables debugging because I see the following line in the maven output:

[INFO] --- android-maven-plugin:3.5.0:apk (default-apk) @ stackx ---
[INFO] Copying local assets files to combined assets directory.
[INFO] Enabling debug build for apk.

有没有明确的方法可以禁用调试?

Is there an explicit way to disable debugging?

推荐答案

查看 更新日志 for Android Maven Plugin 3.5.0 - 2012-12-18 发布:

Check out changelog for Android Maven Plugin 3.5.0 - released 2012-12-18:

注意

由于非发布版本现在默认是可调试的,因此您需要确保在发布版本中将发布参数设置为 true.

Since non-release builds are now debuggable by default you NEED TO ensure that the release parameter is set to true in your release build.

在 pom 中,这将是例如

In the pom this would be e.g.

<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
    <release>true</release>

或者你可以在命令行上使用例如

or you could activate on the command line with e.g

mvn clean deploy -Dandroid.release=true

或者如果您使用发布插件,只需将上述 pom 配置添加到发布配置文件中.

or if you use the release plugin just add the above pom config to the release profile.

com/jayway/maven/plugins/android/phase09package/ApkMojo.java

对于日志管理,一种更优雅和战略性的方法是在项目发布阶段使用 Proguard 删除所有日志调用,请参阅答案 此处 了解更多详情.

For logging management, A more elegant and strategic way is to use Proguard remove all log call at project release phase, see answer here for more details.

这篇关于android-maven-plugin:禁用 apk 的调试构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆