Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android – multiple custom versions of the same app

Whats the best way to deploy several customized versions of a Android application?

Currently I have a script to exchange the resource folder for getting a customized version of my app. It works great, but all custom versions still have the same package name in the AndroidManifest.xml. Therefore it is not possible to install two customized versions of the app at the same time.

This is one solution for this problem, but that has to be done by hand

Can you think of a more easy solution, or how this could be built into a skript?

(btw: it is not for a porn/spam/whatever app, not even a paid one)

like image 318
Ulrich Scheller Avatar asked Aug 03 '09 13:08

Ulrich Scheller


People also ask

Can I install 2 versions of the same app android?

Using the Native Android Cloning FeatureSome Android devices offer native support for app cloning. It lets you run multiple copies of the same app without having to install any third-party tool. This feature is available on Samsung, Xiaomi, Oppo, and OnePlus phones, among others.

How do I install different versions of the same APK?

First install the older version and edit that app with 'App Cloner'. Just change the name of the app. Now, uninstall the app and then install the modified APK. Now install the latest version as well.


1 Answers

Perhaps the built-in Android "library" concept was not fully baked at the time of the original post, but it may be the preferred method as of 2011. Follow these steps for an ant build:

Starting from a working app (let's call it directory "myOrigApp", package com.foo.myapp), just add this line to "default.properties" to make it a library:

android.library=true 

Now create a new app in a sibling directory in any way you prefer (let's call it directory "sibling", package com.foo.myVariant). Using Intellij Idea, for example, create a project 'from scratch' with directory 'sibling' and it will create all the files/directories you would normally need.

In that new, sibling directory edit "default.properties" to add the dependency:

android.library.reference.1=../myOrigApp 

Copy over the Manifest from the original dir:

cd sibling cp ../myOrigApp/AndroidManifest.xml  ../myOrigApp/local.properties ../myOrigApp/build.properties  . 

Edit that copied Manifest file to change its package name to your new variant, "com.foo.myVarient"; that's the only change.

If you just run the ant build scripts, you may be done. (I had to just set up signing keys.)

If you want to set up an IDE like Idea to have the library project as a dependent of the variant project, follow these steps to add a library project to the variant project (assumes you already have a project set up for both):

  • Open the original project, bring up Project Settings, select your Facet and check "Is Library Project" and save.
  • Open the variant project, bring up Project Settings, select Modules
  • Add a module
  • Select “Import existing module”
  • Browse to the Original directory (myOrigApp) and select its .iml file (IntelliJ project source file)
  • Click "Finish." (The library project is added as a module within the variant project.)
  • In the modules list click over the Variant project to select it.
  • On the right hand side select the "Dependencies" tab.
  • Click "Add…"
  • Choose "Module dependency…" (A list should appear that includes the name of the module/library you previously added to the project--perhaps the only entry in the list).
  • Select the library project you added and press OK. (It will be added to the list of dependencies of your project.)
  • Press OK to finish configuring the project. (You should see 2 modules, with the library's resources and classes available and recognized in the Variant project.)
like image 109
larham1 Avatar answered Nov 04 '22 00:11

larham1