创建演示和完整版的应用程序基于一个code基/项目 [英] Creating demo and full version app based on one code base/project

查看:105
本文介绍了创建演示和完整版的应用程序基于一个code基/项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一款使用Android操作系统的应用程序在一个项目中使用Eclipse - 它的结构(从iPhone未来),因此一个常量定义,无论是演示或完整版

I have developed one Android app in one project with Eclipse - it's structured (coming from iPhone) so one constant defines whether it's the demo or the full version.

现在我有一个每次我要创建我需要改变恒定,但也需要使该项目的一个副本,不同的包名试玩版中的问题。

Now I have the problem that everytime I want to create the demo version I need to change the constant but also need to make a copy of the project with a different package name.

显然改变code在原来的完整版需要被复制到演示或我将不得不重新创建演示应用程序每次我提出我的应用程序。

Obviously changing code in the original full version needs to be copied over to the demo or I would have to redo the creation of the demo app everytime I submit my app.

我看到三种可能的方法:

I see three possible approaches:

1。 虽然我已研究过的库项目,目前还不清楚对我来说这真的是如何提供在这种情况下,一个很好的解决方案。

1. While I have looked into library projects it is still unclear to me how this really provides a good solution in this case.

例如,如果我有完整版本的活动结构:

For example if I have the full version with an activity structure:

A1
A2
A3

使用实用工具类U1,U2

using utility classes U1,U2

当然,U1和U2可以在库项目,并从两个项目中引用 - 但活动的strings.xml,图形,布局需要被复制(或有另一种方式,我不明白吗?)这不似乎没有了一个好办法,可惜一直没有在关于这一主题时,此方法被提出类似的问题解释说。

Certainly U1 and U2 can be in a library project and referenced from both projects - but the activities, strings.xml, graphics, layouts need to be duplicated (or is there another way that I don't see?) This does not seem to be a good way forward and unfortunately has not been explained in similar questions on this topic when this approach was suggested.

2。 另一种方法是根据不同的构建设置(类似iPhone),但是,这似乎并不可能在Eclipse中,而不是通过使用一些外部脚本(用于创建不同的包名 - 说实话 - 我宁愿避免因为它似乎而容易出错),同时还编制了以Eclipse的外部调用

2. The other way would be to create different package names based on different build settings (similar to iPhone), however, this does not seem to be possible in Eclipse rather than by using some external scripts (which - honestly - i rather avoid since it seems rather error prone) while also the compilation has to be invoked outside Eclipse

3。 在可能是最直接的方法(也是目前与smalles努力)是刚刚手动复制该项目,改变一个常数,重命名包,每一次我提交编译/导出。这 - 然而 - 似乎是相当基本,当然看起来不专业(相比于iPhone / X code编译设置/目标解决方案)

3. The probably most straight forward approach (and also currently with smalles effort) is to just manually copy the project, change the one constant, rename the package and compile/export every time I submit. This - however - seems to be rather "basic" and certainly does not look professional (as compared to iPhone/xCode build setting/target solution)

什么是最好的方法(需要改变的最小量,仍然是稳定和易于使用)?

What would be the best approach (requiring minimum amount of changes and still being stable and easy to use) ?

非常感谢!

修改

对于大家谁试图蒂姆的解决方案 - 它工作正常,但我遇到了一个问题,自定义属性

For everyone who tried tim's solution - it works fine, however I ran into a problem with custom attributes.

检查:<一href="http://stackoverflow.com/questions/8087744/how-to-solve-android-libraries-custom-attributes-and-package-name-remapping-duri">How解决的Andr​​oid库自定义属性和包名构建过程中重新映射? 这将解决ISSE图书馆

Check this: How to solve Android Libraries custom attributes and package name remapping during build? it will solve the isse for libraries

推荐答案

我在做这个目前在日食,这并不难。

I'm doing this currently in eclipse, and it is not difficult.

  1. 将现有的源库项目。

  1. Convert existing source to library project.

创建两个新的项目,免费和付费。

Create two new projects, free and paid.

包含在免费和付费的项目库项目。

Include the library project in the free and paid projects.

这是没有必要有一个单一的活动或资源的免费/付费项目内。所有你需要的是一个清单为每个referenes活动从资料库中。我的自由和充分的项目,目前还没有一个单一的Java,资源,或任何形式的布局文件,它只是一个清单从库中引用的活动。

It's not necessary to have a single Activity or resource inside the free/paid projects. All you need is a manifest for each which referenes the activities from your library. My free and full projects do not currently have a single java, resource, or layout file of any kind, it's just a manifest which references activities from the library.

我用的是完全相同的code这两个项目,我区分他们说:

I use the exact same code for both projects, and I differentiate them by saying :

if(getApplicationContext().getPackageName().equals("full version package name")) {
    //do full stuff
} else {
    //do free stuff
}

一些陷阱我已经打了,特别是如果你已经发布了市场上的应用程序:

Some gotchas I've hit, especially if you've already released your app on the market:

  • 如果您更改任何活动的全名/路径,它会消失,从您的主屏幕。因此,如果你的库比现有版本不同的软件包名称,你将失去任何主屏幕图标。它们可以由用户进行更换,但它不是理想的。
  • 相似appwidgets,如果你改变自己的接收器的名字,他们就会消失在升级。
  • 您可能不会在任何情况下更改发布应用程序的包名。

如果您已经发布了一个免费和专业版,它有点不幸,因为活动路径将需要更改为一个公共库路径,你不能重命名发布的包相匹配的库路径。因此,有人将失去现有的图标。

If you've already released a free and pro version, it's somewhat unfortunate, because the activity path will need to change to a common library path, and you can't rename the released package to match the library path. So somebody will have to lose their existing icons.

在我的情况下,我只发布了一个免费的版本分裂之前,我是能够去图书馆与相同的包名称的是免费版的名称。我很怀疑,你会被允许包括与相同的包名称包装包装出库,但显然它是可以这样做(工作对我罚款)。

In my case I had only released a free version before splitting them, and I was able to name the library with the same package name as the free version. I was skeptical that you'd be allowed to include a library with the same package name as the wrapper package, but apparently it's possible to do so (working fine for me).

所以,在我的情况我有三个项目:

So in my case I've got three projects:

  • 核心库:包名称:com.myname.myapp <​​/ li>
  • 免费版本:包名称:com.myname.myapp <​​/ li>
  • Pro版本:包名称:com.myname.myapp.Pro
  • Core Library: package name : com.myname.myapp
  • Free Version: package name : com.myname.myapp
  • Pro Version: package name : com.myname.myapp.Pro

和自由的和完全版的表现增加 com.myname.myapp.ActivityA 这是命名的活动或 com.myname.myapp.ActivityB ,只有在库项目中存在。

And the free and full version manifests add activities which are named com.myname.myapp.ActivityA or com.myname.myapp.ActivityB, which exist only in the library project.

这篇关于创建演示和完整版的应用程序基于一个code基/项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆