如何保持同一安卓应用程序的两个版本?[英] How to keep two versions of the same android app?

本文是小编为大家收集整理的关于如何保持同一安卓应用程序的两个版本?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

经常看到两个版本的Android应用程序:付费版本和免费版本.我还开发了一个想要发布两个版本的应用程序.做这个的最好方式是什么?在两者之间创建两个项目和复制文件似乎并不是我心中的最佳方式.

推荐答案

更新:此方法只适用于使用Eclipse编译,因为Android Studio支持 build flavors ,它可以恰好实现这一点.


@ Yorkw's和@ nate的答案都是好的,这个是我使用的方法我的简单性.从文章:

  • com.example.myapp - android项目库 - 这是我整个应用程序的生活.完整和Lite版本的所有功能.
  • com.example.myapp.full - android应用程序项目 - 这是一个shell,其中仅包含完整版本所需的图形和资源.基本上它是一个超级轻便的壳.
  • com.example.myapp.lite - android应用程序项目 - 这是另一个包含Lite版本所需的图形和资源的shell.同样,它是一个超级轻便的壳.

我还在图书馆类中保留一个静态变量IS_PRO,在该应用程序启动时设置.这应该仅用于通知,警报等(例如要求用户升级到Pro).

但是,此方法具有一个缺点:您必须清洁和重建任何时间库或其资源都被修改.也一定是阅读这篇文章在项目和图书馆之间共享资源.

本文地址:https://www.itbaoku.cn/post/102328.html

问题描述

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.