How to create multiple apks from one project?

I have one project for Android where I need to create several apks. The only difference between each apk will be the name of the package (e.g. com.my.package.name) and the name of the application string so that I can install multiple instances of the application on the same device. Is there a better way to do this? I thought about creating a library project, but I thought that there might be an easier way to do this.

+4
source share
7 answers

I actually used apktool to decompile apk and then edited the smali files with some Perl script to change the name of the package.

0
source

You can put your main code in the library and create several neighbor projects that generate several APKs:

I tested this and was much simpler than I thought: fooobar.com/questions/287636 / ...

+2
source

A library design is the right way to do this. You create and work on a library project and have a project for each version, which depends on the library project. Do not forget that for each project you must have the correct Androidmanifest.

+1
source

You can try the new Android build system. Here are some links

You can configure the following properties:

  • minSdkVersion
  • targetSdkVersion
  • Versioncode
  • versionName
  • package name (overrides the value from the manifest)
  • etc..
+1
source

You can use productFlavors in application level gradle.

flavorDimensions "tier" productFlavors { dev { dimension "tier" buildConfigField "String", "URL", "\"http://glapp/demo.php\"" buildConfigField "boolean", "ENABLE_DEBUG", "false" versionName = android.defaultConfig.versionName + " dev" applicationId = "com.abc.glnewapp.dev" resValue "string", "app_name", "GL Demo" } prod { dimension "tier" buildConfigField "String", "URL", "\"http://glapp/live.php\"" buildConfigField "boolean", "ENABLE_DEBUG", "false" applicationId = "com.abc.glnewapp.prod" resValue "string", "app_name", "GL Live" } } 

Then select the build option to build apk according to the variable. You can put a lot of flour (different apk) as you want.

enter image description here

You can change the application icon and other drawings by adding the same res structure to the falour name folder in the src directory. Also, if you find any problem with google json, just copy google json file to src-> productflavour

For more information, visit at

+1
source

You cannot programmatically change the package name. Therefore, the only solution is to change it manually and create apk .

0
source

To change the package name, you can do this:

You will need to duplicate the project. Right-click one at a time, select "Android Tools → Rename Application Suite"

I hope for this help.

0
source

Source: https://habr.com/ru/post/1443730/


All Articles