15

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

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.)

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

I use the following plugins:

  1. maven-compiler-plugin
  2. maven-jarsigner-plugin
  3. proguard-maven-plugin
  4. android-maven-plugin with zipalign goal and configuration.

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?

yorkw
  • 40,926
  • 10
  • 117
  • 130
Prasanna
  • 3,703
  • 9
  • 46
  • 74

1 Answers1

34

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

ATTENTION

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

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

Source Code:

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

Related Pull Request:

Off Topic:

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.

Community
  • 1
  • 1
yorkw
  • 40,926
  • 10
  • 117
  • 130
  • this worked, thanks. regarding log management using proguard, I have tried it but I an messing it up somewhere as I still see log statements – Prasanna Feb 24 '13 at 23:54
  • I've added true to my profile just as you specified above but release builds still seem be setting debug? The second method of using -Dandroid.release=true seems to work, but any ideas why it's not working in the pom? Also tried setting it as shown in http://antew.com/?p=150 but no luck. – brk3 Mar 06 '13 at 14:01
  • Hard to tell without seeing your pom.xml, if you follow the sample project and set `true` in release profile, to active it, run `mvn clean install -Prelease`, or if you use maven-release-plugin, run `mvn release:prepare`. – yorkw Mar 06 '13 at 20:08
  • it works for me, thanks. I can clearly see while building: Enabling release build for apk. – MartinC May 05 '14 at 12:44
  • Thanks very much. Helped me to deploy to the store. I don't understand what's the intention of this change because when I say debug yes or no, why is that not enough. – Bevor Oct 25 '14 at 16:08