Multi-branded App - How to set application id

Hello,
I have a xamarin form app and I need to deploy different branded app using 'Configurations' and 'Pre-Build' scripts.
iOS side I was able to solve my problems, the app has different configuration file, resources and bundle id.

My problem is on Android side.
I was able to modify resources...but now I need to change, for each branded version, the applicationid.
I see that in AndroidManifest.xml there is '${applicationId}' variable...
In witch way I can modify this value? Or, in other words, in file this value is stored?

ps. I made the same things using Android Studio and gradle and was easy using flavor and build variants

Thanks a lot

Best Answer

  • MatteoPiccioniMatteoPiccioni US ✭✭
    Accepted Answer

    Hello,
    sorry for the late answer

    The steps I wrote some some time ago, are not working 100% times...for some reason only after several 'clean-rebuild-delete-debug-obj-folder' cycle the application id is updated...is not clear in wich way and when the application-id is 'refreshed' by Visual Studio (I use Mac version)

    The application-id and package are not the same thing! Maybe at start of Android history, but not now.
    The package name is used to refer to your R class and imports...the package name should always match the package attribute in the AndroidManifest.xml
    Using Android Studio and gradle is really simple to have different brand apps...the application-id identify your app in Google Play. Once the app has been published to Google Play, the application-id should never be changed.
    In Android Studio is declared in the build.gradle and using 'flavors' you can make in easy way different version of your app.

    In xamarin development I was not able to separate the concept of application-id from the package-name...what I understand is that in xamarin the application-id is created (in some way) with the same name of the package name.
    For solve my needs I made different configuration..one for each brand...in pre-build script I copy resources (and AndroidManifest.xml modified ad-hoc with the right package value) into source code directory at the right directory (overwriting files).
    With much difficulty, in some way (using the steps I wrote in previous posts), I was able to have a apk with updated application-id.
    Before release, be careful to test and look the apk to be sure that the application has been updated.

    ps. sorry for my english :neutral:

Answers

  • MatteoPiccioniMatteoPiccioni USMember ✭✭
    edited September 2017

    Ok, I was able to find the problems...

    The steps:

    1) Create and configure different configurations inside the solution and inside the .Droid project

    2) Depends the configuration selected, write a pre-build action script the will copy resources and file at right places

    3) For each branded version of the app I modify the 'package' value into the AndroidManifest.xml
    This will be the application-id

    (bug 1)
    While compiling I had the error:
    'Deployment failed because of an internal error: Could not find a part of the path ..bla bla'
    4) Open file 'nameprj.Droid.csproj'
    Inside file 'nameprj.Droid.csproj' the <OutputPath> was filled with a path different from the default one (the working default app).
    <OutputPath>.</OutputPath> is the right value.

    (bug 2)
    5) Even if I select the brand version of the app, the output was always the default version of the app!
    Opening again the 'nameprj.Droid.csproj' I saw the was wrong.
    In fact the default configuration was still selected:
    <Configuration Condition=" '$(Configuration)' == '' ">BaseApp_Debug</Configuration>
    So I need to change the 'BaseApp_Debug' into 'BrandA_Debug'

    Now I am able to deploy with a single project different version of the same app (different resources, app-id, etc etc)

    I hope it can be of help to someone

  • HemantaHemanta INMember ✭✭

    Hi Matteo Piccioni, I have similar requirement. I have to change ApplicationID depending upon Brand value.
    I just created separate Manifest_XXX.xml file depending upon Brand and from .csproj file [As per configuration]referred to that specific Manifest_XXX.xml file. In that Manifest_XXX.xml I just modified the Package name.


    Properties\AndroidManifest_167.xml

    Is this Approach Correct ??

    Is Application ID is same as Package name, Which needs to be changed in Manifest.xml file ?

    Could you please share any sample example ..??

    Thanks a lot.

  • HemantaHemanta INMember ✭✭

    @MatteoPiccioni ... Clould you please help.. ??

  • MatteoPiccioniMatteoPiccioni USMember ✭✭
    Accepted Answer

    Hello,
    sorry for the late answer

    The steps I wrote some some time ago, are not working 100% times...for some reason only after several 'clean-rebuild-delete-debug-obj-folder' cycle the application id is updated...is not clear in wich way and when the application-id is 'refreshed' by Visual Studio (I use Mac version)

    The application-id and package are not the same thing! Maybe at start of Android history, but not now.
    The package name is used to refer to your R class and imports...the package name should always match the package attribute in the AndroidManifest.xml
    Using Android Studio and gradle is really simple to have different brand apps...the application-id identify your app in Google Play. Once the app has been published to Google Play, the application-id should never be changed.
    In Android Studio is declared in the build.gradle and using 'flavors' you can make in easy way different version of your app.

    In xamarin development I was not able to separate the concept of application-id from the package-name...what I understand is that in xamarin the application-id is created (in some way) with the same name of the package name.
    For solve my needs I made different configuration..one for each brand...in pre-build script I copy resources (and AndroidManifest.xml modified ad-hoc with the right package value) into source code directory at the right directory (overwriting files).
    With much difficulty, in some way (using the steps I wrote in previous posts), I was able to have a apk with updated application-id.
    Before release, be careful to test and look the apk to be sure that the application has been updated.

    ps. sorry for my english :neutral:

Sign In or Register to comment.