18

I want to create my Android app in release mode. I did the suggested Export from Eclipse. Android tools -> Export Unassigned ( then signed it aligned it etc ) I though the export would give me release mode app. I checked on disk and the .apk is just the same size as the one I get when I normally compile in Eclipse.
Further I installed it in the emulator by >adb install myapp.apk then I tried to attach to the application in the Eclipse debugger and sure enough it hit my breakpoint. So I'm convinced I have indeed a debug version. The question is how can I create release mode version of my application from Eclipse before signing and submitting to the market place ?

Edit

If I log it the debuggable flag is off when exported, as well when running from Eclipse. Unless I explicitly set it to true in the Manifest application section. It seems the debug / release mode is just a flag on / off. Doesn't do anything more than that, I can set breakpoints and debug both versions. The resulting .apk is the same size.

cxLog.e( "TOKEN", " Debuggable=" + (( context.getPackageManager().getApplicationInfo( comp.getPackageName(), 0 ).flags &= ApplicationInfo.FLAG_DEBUGGABLE ) != 0 ) ); 

10-28 14:46:12.479: ERROR/TOKEN(1856): Debuggable=false

Orn Kristjansson
  • 3,435
  • 4
  • 26
  • 40
  • 2
    Good question. I am new to android development, and it seems to me what should be a one click process (export in release mode), is actually a horrendous compendium of options, editing the code to remove Log calls, optimizing (or not) etc etc. Perhaps a sign of lack of mature leadership in the Android dev team. I see this is marked as answered - but what is the solution? I am on SDK 16, and am hitting the same issues... I started with reading the Android docs - so links back to that have not helped me... – Peter B Feb 10 '13 at 19:17

3 Answers3

17

The question is how can I create release mode version of my application from Eclipse

Check this out : Compile the application in the release mode

Android Tools > Export Unsigned Application Package


Support for a true debug build. Developers no longer need to add the android:debuggable attribute to the tag in the manifest — the build tools add the attribute automatically. In Eclipse/ADT, all incremental builds are assumed to be debug builds, so the tools insert android:debuggable="true". When exporting a signed release build, the tools do not add the attribute. In Ant, a ant debug command automatically inserts the android:debuggable="true" attribute, while ant release does not. If android:debuggable="true" is manually set, then ant release will actually do a debug build, rather than a release build.

Community
  • 1
  • 1
Reno
  • 33,594
  • 11
  • 89
  • 102
  • What happen if i use "Export Signed Application Package" will it auto sign my apps and zipallign it? – xDragonZ Oct 28 '11 at 03:20
  • @Orn hmm the documentation says something else, which version of SDK are you using, Also try to use ProGuard, maybe that can remove unwanted debug symbols? – Reno Oct 28 '11 at 03:36
  • @xDragonZ Jepp, it will do exactly that. – Reno Oct 28 '11 at 03:36
  • 1
    My Android sdk is at 7, seems 15 is out already, maybe time to update – Orn Kristjansson Oct 28 '11 at 23:23
  • Also try "Select the project in the Package Explorer and select File > Export." from http://developer.android.com/tools/publishing/app-signing.html#ExportWizard worked for me. – Diederik Oct 02 '12 at 05:31
  • @xDragonZ - yes, according to [Compile and sign with Eclipse ADT](http://developer.android.com/tools/publishing/app-signing.html#ExportWizard): "Complete the Export Wizard and your application will be compiled, signed, aligned, and ready for distribution." – rundavidrun Oct 21 '12 at 06:46
4

If you want to SIGNED IN and ZIP ALIGNED your app in release mode so that it could distribute and can be uplodated to the Google play store, then just follow the below steps.

 --> Right click on project
 --> Android Tools
 --> Export Unassigned app and save in directory like D:\Sdcard.apk

         //Now open your windows terminal, CMD
 --> change directory to the bin of the jave like
 --> cd c:\ProgramFiles\JAVA\JDK\bin

Now this is time to create Keystore Released File... now write these commands in the TERMINAL,

keytool -genkey -v -keystore my-release-key.keystore -keyalg RSA -keysize 2048 -validity 14600

This will propmt for Keystore "password" and for Key "password", so type different password and answer to the question it will ask later. Now my-release-key.keystore file will be generated in directory where your "bin" folder of java are, like in my sytstem it will be like

     c:\ProgramFiles\JAVA\JDK\bin\ my-release-key.keystore

write this command in Terminal for Signed in the app

jarsigner -verbose -keystore my-release-key.keystore D:\Sdcard.apk mykey

Now redirect your terminal to the Zipalign.exe file which is located in Android sdk 21\tool\ , like in my system i did that

cd F:\Softwares\LANGUAGES SOFTEARE\Android Setup\android-sdk-21 version\tools

After that put the below line in the terminal

zipalign -v 4 D:\Sdcard.apk newSdcard.apk

Congratulations! - Now you will find a newSdcard.apk file inside the Android sdk\tool, Now upload it to play store, and remember me with love.

Karl Taylor
  • 4,839
  • 3
  • 34
  • 62
Pir Fahim Shah
  • 10,505
  • 1
  • 82
  • 81
0

On current versions of the Android SDK, just right-click the project, Android Tools > Export Signed Application Package, and select your keystore

slinden77
  • 3,378
  • 2
  • 37
  • 35