解决方法
例如(不基于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.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。