How to create various Android apps using ant scripts

Hi, I am creating my own application. PRE:

  • The application will be limited to a limited number of users. (say 20 people).
  • The application must be unique for each user, so each apk will only refer to the user.
  • Each application must have a different package name.

So, I started thinking about building a script that takes a list of users and creates 20 apks (one for each user) and updates the strings.xml file with the user modification needed for each user.

But I really don't know where to start. Is there a good way or tutorial that I can reference?

Just to be clear, I would like to have a manifest like this:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="$pname"
    android:versionCode="1"
    android:versionName="1.0">
        <application>...</application>
    </manifest>

And then replace $ pname using ant.

+3
4

, aapt. -rename-manifest-package.

 Rewrite the manifest so that its package name is the package name
 given here.  Relative class names (for example .Foo) will be
 changed to absolute names with the old package so that the code
 does not need to change.
+1

20 ( ), 20 , 1 , :

mypackage.user01.MyMainActivity extends mypackage.MyMainActivity;
mypackage.user02.MyMainActivity extends mypackage.MyMainActivity;
mypackage.user03.MyMainActivity extends mypackage.MyMainActivity;
...
mypackage.user20.MyMainActivity extends mypackage.MyMainActivity;

20 androidmanifests.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="mypackage.userXX">
    <application
            android:icon="@drawable/MyIcon"
            android:label="@string/MyApplication"
           >
        <activity android:name=".MyActivity"
                  android:label="@string/MyActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
                android:name="mypackage.MyActivity"
                android:label="@string/MyActivity"/>
        <activity
                android:name="mypackage.user01.MyActivity"
                android:label="@string/MyActivity"/>
        <!-- etc. till user20 -->
    </application>
</manifest>

Ant - , :)

+1

, 20 . . , .

If that sounds like the right approach, I'll see if I can code some specific aspects. If this is not the approach you need, please could you give me a little more information on how these 20 people will be identified?

0
source

You can also use a unique device identifier. The Android Developers Blog had an interesting article.

If you want to create a build script, you can use Ant .

0
source

All Articles