Android的Maven的插件:禁用调试版本的APK [英] android-maven-plugin: Disable debug build for apk

查看:181
本文介绍了Android的Maven的插件:禁用调试版本的APK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不清楚禁用调试版本建立与Android的Maven的插件而准确的方法:

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

据我所知,与ADT(21.1)导出向导会自动禁用调试,但它被打破的BuildConfig.DEBUG总是返回真,我的日志用于依赖于它。 (现在我有我自己的财产在我的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的插件禁用调试,什么是正确的方式做到这一点?

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-插件
  3. ProGuard的-Maven的插件
  4. Android的Maven的插件使用zipalign目标和配置。

我不知道签署和自动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?

推荐答案

查看更新日志为Android Maven插件3.5.0 - 发布二〇一二年十二月十八日:

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

注意

ATTENTION

由于非发行版本现在默认情况下调试的,你需要确保释放参数设置为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.

在聚甲醛,这将是例如。

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.

<一个href="https://github.com/jayway/maven-android-plugin/blob/master/src/main/java/com/jayway/maven/plugins/android/phase09package/ApkMojo.java#L1149">com/jayway/maven/plugins/android/phase09package/ApkMojo.java

  • Non-release builds will now automatically be debuggable
  • Support BuildConfig generation

有关记录的管理,更优雅的和战略性的方法是使用Proguard的去除,在项目发布阶段所有日志呼叫,请参阅回答<一href="http://stackoverflow.com/questions/12390466/android-proguard-not-removing-all-log-messages/12396486#12396486">here了解更多详情。

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的插件:禁用调试版本的APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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