问题描述
经常看到两个版本的Android应用程序:付费版本和免费版本.我还开发了一个想要发布两个版本的应用程序.做这个的最好方式是什么?在两者之间创建两个项目和复制文件似乎并不是我心中的最佳方式.
推荐答案
更新:此方法只适用于使用Eclipse编译,因为Android Studio支持 build flavors ,它可以恰好实现这一点.
@ Yorkw's和@ nate的答案都是好的,这个是我使用的方法我的简单性.从文章:
我还在图书馆类中保留一个静态变量IS_PRO,在该应用程序启动时设置.这应该仅用于通知,警报等(例如要求用户升级到Pro).
但是,此方法具有一个缺点:您必须清洁和重建任何时间库或其资源都被修改.也一定是阅读这篇文章在项目和图书馆之间共享资源.问题描述
It's quite often that we see two versions of an android app: a paid version and a free version. I'm also developing an app that would like to release two versions. What is the best way to do this? Creating two projects and copying files in between does not seem to be the best way in my mind.
推荐答案
Update: This method is really only good for compiling with Eclipse, since Android Studio supports build flavors which can achieve exactly this.
While @yorkw's and @Nate's answers are both good, this is the method I use due to its simplicity. From the article:
- com.example.myapp – Android Project Library - This is where my ENTIRE app lives. All the functionality for the FULL and LITE versions.
- com.example.myapp.full - Android Application Project - This is a shell that contains graphics and resources needed for the full version only. Basically it’s a super lightweight shell.
- com.example.myapp.lite - Android Application Project – This is another shell that contains nothing but graphics and resources needed for the lite version. Again, its a super lightweight shell.
I also keep a static variable IS_PRO in a library class which is set when the app launches. This should be used only for notifications, alerts, and so on (such as asking the user to upgrade to pro).
However, this method has one drawback: you must clean and rebuild any time the library or its resources are modified. Also be sure to read this post on sharing resources between a project and a library.