简体   繁体   English

创建Android应用发布模式

[英]Create Android app release mode

I want to create my Android app in release mode. 我想在发布模式下创建我的Android应用。 I did the suggested Export from Eclipse. 我做了Eclipse的建议导出。 Android tools -> Export Unassigned ( then signed it aligned it etc ) I though the export would give me release mode app. Android工具 - >导出未分配(然后签名对齐它等)我虽然导出会给我发布模式应用程序。 I checked on disk and the .apk is just the same size as the one I get when I normally compile in Eclipse. 我检查了磁盘,而.apk的大小与我在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. 此外,我通过> adb install myapp.apk将它安装在模拟器中,然后我尝试连接到Eclipse调试器中的应用程序,确定它已经达到了我的断点。 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 ? 问题是如何在签署并提交到市场之前从Eclipse创建我的应用程序的发布模式版本?

Edit 编辑

If I log it the debuggable flag is off when exported, as well when running from Eclipse. 如果我记录它,则在导出时以及从Eclipse运行时,debuggable标志会关闭。 Unless I explicitly set it to true in the Manifest application section. 除非我在Manifest应用程序部分中明确地将其设置为true。 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. 得到的.apk大小相同。

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 10-28 14:46:12.479:ERROR / TOKEN(1856):Debuggable = false

The question is how can I create release mode version of my application from Eclipse 问题是如何从Eclipse创建我的应用程序的发布模式版本

Check this out : Compile the application in the release mode 检查一下: 在发布模式下编译应用程序

Android Tools > Export Unsigned Application Package Android工具>导出未签名的应用程序包


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. 开发人员不再需要将android:debuggable属性添加到清单中的标记 - 构建工具会自动添加属性。 In Eclipse/ADT, all incremental builds are assumed to be debug builds, so the tools insert android:debuggable="true". 在Eclipse / ADT中,假设所有增量构建都是调试构建,因此工具插入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. 在Ant中,ant debug命令会自动插入android:debuggable =“true”属性,而ant release则不会。 If android:debuggable="true" is manually set, then ant release will actually do a debug build, rather than a release build. 如果手动设置android:debuggable =“true”,那么ant release实际上会进行调试构建,而不是发布构建。

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. 如果您想要在发布模式下签名和ZIP对齐您的应用,以便它可以分发并可以升级到Google Play商店,那么只需按照以下步骤操作即可。

 --> 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, 现在是时候创建Keystore Released File ...现在在TERMINAL中编写这些命令,

keytool -genkey -v -keystore my-release-key.keystore -keyalg RSA -keysize 2048 -validity 14600 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 现在my-release-key.keystore文件将在java的“bin”文件夹所在的目录中生成,就像在我的sytstem中一样,它会像

     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 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 现在将您的终端重定向到Zipalign.exe文件,该文件位于Android sdk 21 \\ tool \\中,就像在我的系统中我做的那样

cd F:\\Softwares\\LANGUAGES SOFTEARE\\Android Setup\\android-sdk-21 version\\tools 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 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. - 现在你会在Android sdk \\ tool中找到一个newSdcard.apk文件,现在将它上传到Play商店,并记住我的爱情。 💖 💖

在当前版本的Android SDK上,只需右键单击项目,Android工具>导出签名的应用程序包,然后选择您的密钥库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM