Android和Eclipse 2同一个应用程序的不同版本

Android和Eclipse 2同一个应用程序的不同版本,第1张

概述你好我是一个开始 Android开发人员使用Windows和eclipse IDE开发java android应用程序.我已经发布了一个游戏,但有一个免费版本的游戏和付费版本.谷歌市场坚持认为不同的版本必须有不同的包名.到目前为止,我一直在使用2个不同的名称重构包,并在每次构建不同版本时更改R资源文件导入.两个版本的代码都是99%相同.有更好的方法吗? 您对此主题 here和 there进行了各种 你好我是一个开始 Android开发人员使用windows和eclipse IDE开发java androID应用程序.我已经发布了一个游戏,但有一个免费版本的游戏和付费版本.谷歌市场坚持认为不同的版本必须有不同的包名.到目前为止,我一直在使用2个不同的名称重构包,并在每次构建不同版本时更改R资源文件导入.两个版本的代码都是99%相同.有更好的方法吗?解决方法 您对此主题 here和 there进行了各种讨论,但基本上解决方案类似于复制项目.

例如(不基于eclipse):

It is difficult to answer this,since we don’t kNow what the difference is between the free and not-free versions of your app.

I’m going to assume that the differences Could be handled by some sort of global free/not-free flag. By that,I mean that the same code would make up both versions of the app,and which portions are enabled or used would be dependent on some public static data member somewhere:

if (SomeClass.IS_PAID_APP) {         // add more stuff to menu,etc. }

If you can organize your app that way,then you only need one code base.
Have it set to build your app one way (free or paID,your choice) and with the proper package in your manifest for that version of the app.
Then,add an Ant task that does the following:

Makes a tree copy of your project dir to a temporary location Switch the copy of the manifest to the new package name via a
search-and-replace Switch all import statements for your old package’s edition of R to
the new package,again via search-and-replace,and again on the copy,
not your original Change your IS_PAID_APP (or whatever) to the opposite value
(search-and-replace in the copy) Executes an Ant build for the copy of the project copIEs the binarIEs from that build to the main project’s bin/
directory under a distinct name (so it doesn’t clobber your other copy
of the APK) Deletes the tree copy made in step #1

If Java had a pre-processor,this would be somewhat simpler. However,the basic technique that I describe above has been used for a couple of decades Now. It’s clunky,but it works,and it means you only have one set of source code to deal with.
Note that the Ant <replace> task would handle your search-and-replace stuff nicely.

总结

以上是内存溢出为你收集整理的Android和Eclipse 2同一个应用程序的不同版本全部内容,希望文章能够帮你解决Android和Eclipse 2同一个应用程序的不同版本所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1136004.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存