How to keep two versions of the same android app?

2020-07-23 06:50发布

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.

5条回答
Emotional °昔
2楼-- · 2020-07-23 07:16

U can use git for example.

Create branch "app_with_ads", and master will be your "paid" version. Develop in master and merge periodically to another.

before publish u probably will have to change app package, or something else in Android\ Manifest.xml

查看更多
Emotional °昔
3楼-- · 2020-07-23 07:18

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.

查看更多
▲ chillily
4楼-- · 2020-07-23 07:20

I would call this a FORK in development. Start a new App development, but have your common code coming from a common file location. Make your free based edits to the forked code, and try your best to keep that code completely separate.

I actually did this on an iPhone based app, I have a free version and 2 different payed versions (a single player only and a multi-player). I would do it the same way on Android.

查看更多
\"骚年 ilove
5楼-- · 2020-07-23 07:23

Here's a little blog tutorial about doing this.

Basically a howto for building a Full and Lite version of the same app, using a library project to accomplish code reuse between the two versions.

查看更多
在下西门庆
6楼-- · 2020-07-23 07:33

Use Library Project, as the official dev guide suggested:

If you have source code and resources that are common to multiple Android projects, you can move them to a library project so that it is easier to maintain across applications and versions. Here are some common scenarios in which you could make use of library projects:

  • If you are developing multiple related applications that use some of the same components, you move the redundant components out of their respective application projects and create a single, reuseable set of the same components in a library project.

  • If you are creating an application that exists in both free and paid versions. You move the part of the application that is common to both versions into a library project. The two dependent projects, with their different package names, will reference the library project and provide only the difference between the two application versions.

查看更多
登录 后发表回答