Creating an Android project for different packages

I am trying to find the best way to create / package an Android application for 6+ different clients. I can use different branches in SVN for all clients, but the only difference between applications is some values ​​in the resource folder (drawings, lines, etc.).

I wrote an ant script that imports the standard Android build.xml . This script does the following:

  • Reads client names from the properties file.
  • For each client, the following is performed:
    • The package name in AndroidManifest.xml is changed (by connecting to the -pre-build target).
    • User resources are copied to the res directory in the assembly (by connecting to the -pre-compile target).
    • The package name will be changed to the default value (by connecting to the target -post-compile ).
    • The APK is copied to a specific location with a name called client-versionno.apk .

This seemed to work well until I just wrote the part that changes the package name. Because of the package name change, the location of the class R also changes, which means that the assembly failed because the Java classes import the class R from the standard package.

I do not want to have a script construct that modifies the code. I want to be able to do this with minimal changes to any files.

Su ... questions really:

  • Are there any good / easy solutions for my problem?
  • Am I getting this problem wrong? Are there any better ways to easily package the same application on 6+ different clients?
+4
source share
2 answers

Is it possible to solve this problem with 6+ different projects, which include your main project. This way you can override resources and make different apk

+1
source

Do you really need to change the package name? Changing the package name is a pain that needs to be done automatically. That being said, here is my solution to the problem:

My scenario is that I have one application that is deployed in 30-200 different signed APK files, where the only difference between the files is some resources (drawings, lines, values, etc.) and the package name.

I do this while working on a generic version of an application that serves as a template project. When this is done, and I'm ready to deploy, I invoke a bash script that performs the following steps for each goal:

  • Clear project completely
  • Change the name and package name with sed.
  • Creates and Signs APK

This balances the terrible time with the fast development time. I really don't see another more elegant / reliable solution than this.

And finally, a little tip: in the android manifest, use relative package names such as ".Application" instead of "com.mycompany.myproject.Application". Thus, you only need to change the package name in ONE place.

+4
source

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


All Articles