Android Question [SOLVED] I'm lost : multiple versions of the same app

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello,
I am lost with the best way of using conditional symbols and AdditionalRes. Please, could you help me or point me to any post I would have missed ?

My need is to generate multiple apps from the same code. Easy in my mind since I saw I will have to have different icons and ProjectAttributes.

At the first time, I have thought to have many #If to change the ApplicationLabel for each version. But perhaps does it exist a more elegant way to do (for example : #If Version1,Version2 ? or Else ?)

At the second time, I have thought about the icons and other bitmaps. And this is what I don't understand. Could I use AdditionalRes to modify my icons ? I guess I would have to point to a separated \res folder. And if this is true, how may I replace the bitmaps inside the \Files folder ?

Perhaps did I not well understood the way to do, I always get an error while trying. Any help is greatly appreciated.
Many thanks :)
 

sorex

Expert
Licensed User
Longtime User
Why not include them all and use selective bitmap load commands or use a different array with the filenames?
ok, it bloats the apk with unneeded images but since it's another app it's already in a different working folder? you can trash 'm there.

on the other hand...

since most code is the same why not put that in a code module that you access from the different B4A files?
just keep the bare stuff like image references in the B4A.

I would personally use the IF stuff to leave out payed version features or so.
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User
I find the Conditional Compile along with Custom Build Actions to be extremely powerful. Here is the top 20 or so lines from one of my apps:

B4X:
#Region Module Attributes
  #FullScreen: True
  #IncludeTitle: False
#If FREE
  #ApplicationLabel: xxx
#End If
#If PLUS
  #ApplicationLabel: xxx Plus
#End If
  #VersionCode: 11
  #VersionName: 5.1
  'SupportedOrientations possible values: unspecified, landscape or portrait.
  #SupportedOrientations: landscape
  #CanInstallToExternalStorage: True
  #AdditionalRes: C:\Android\android-sdk\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#End Region

#If FREE
  #CustomBuildAction: 1, c:\windows\system32\cmd.exe, /c copy ..\files\xxxicon.png res\drawable\icon.png
 
  #If GOOG
    #CustomBuildAction: 1, c:\windows\system32\cmd.exe, /c copy ..\GoogAmzn\upgoog.html ..\Files\xxxupg.html
    #CustomBuildAction: 1, c:\windows\system32\cmd.exe, /c del /Q ..\objects-goog\*.*
    #CustomBuildAction: 4, c:\windows\system32\robocopy.exe, ..\objects ..\objects-goog
  #End If
  #If AMZN
    #CustomBuildAction: 1, c:\windows\system32\cmd.exe, /c copy ..\GoogAmzn\upamzn.html ..\Files\xxxupg.html
    #CustomBuildAction: 1, c:\windows\system32\cmd.exe, /c del /Q ..\objects-amzn\*.*
    #CustomBuildAction: 4, c:\windows\system32\robocopy.exe, ..\objects ..\objects-amzn
  #End If
#End If
#If PLUS
  #CustomBuildAction: 1, c:\windows\system32\cmd.exe, /c copy ..\files\xxxpicon.png res\drawable\icon.png
  #CustomBuildAction: 1, c:\windows\system32\cmd.exe, /c del ..\Files\xxxupg.html
  #CustomBuildAction: 1, c:\windows\system32\cmd.exe, /c del /Q ..\objects-plus\*.*
  #CustomBuildAction: 4, c:\windows\system32\robocopy.exe, ..\objects ..\objects-plus
#End If

upload_2014-8-6_10-53-35.png



upload_2014-8-6_10-55-13.png



I use Custom Build Actions to select one of two different icons and different HTML files to be used depending on Free versus Plus build. I make a backup copy of the output of a build into a special directory.

Within a Free build I have to modify things further depending on whether it will be uploaded to Google Play or the Amazon Appstore. I use the Conditional Compile symbol G00G or AMZN to select one or the other. I disable a symbol by putting an x in front of it. This lets me disable it while still seeing that the symbol exists.

I found most of this procedure in the various tutorials and examples from Erel.

Barry.
 

Attachments

  • upload_2014-8-6_10-51-15.png
    upload_2014-8-6_10-51-15.png
    30.9 KB · Views: 275
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
I do thank you Barry. That's absolutely what I was missing. Thanks for having shared this useful example.
 
Upvote 0
Top