Android Question CustomBuildAction is it reliable ?

Discussion in 'Android Questions' started by itgirl, Feb 14, 2015.

  1. itgirl

    itgirl Active Member Licensed User

    [wrong forum :( sorry hopefully Erel will move it to questions]

    Hey guys lately i have been working on some project which needs a lot of translation in the res folder and i was so tired of removing the Readonly for the strings.xml but after a couple researches in the formus i found a good way to avoid all this using CustomBuildAction which is a very useful thing to have you can read more about it HERE

    in short

    #CustomBuildAction: 1, c:\windows\system32\attrib.exe, +r res\*.* /s
    #CustomBuildAction: 5, c:\windows\system32\attrib.exe, -r res\*.* /s
    first line: code will be parsed then it will mark the res folder as readonly

    second line : comes the amazing second line which re-marks your res folder as readable after the APK was installed so you don't have to mark files again.

    I don't know why this is not the default behavior of B4A in the first place but i guess there's a good reason behind it . have fun
    Last edited: Feb 14, 2015
  2. DonManfred

    DonManfred Expert Licensed User

    You dont need to use such tricks (i dont know if this i reliable or maybe changed in future.

    I would suggest to use additionalresources instead. Here you dont need to set the files to readonly.

    See example:

    Here you have an folder Resources inside your projectdir. ALL files in THIS folder does not need the readonly-flag.
    Put everything what you did in objects/res/ into this folder.

    Then, in your project, you can use
    #Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
        #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #AdditionalRes: ../resources
    #End Region
    to tell b4a to use this folder as additional resource.

    If you show me which files in objects/res/ you change then i can show you how to change it.
    No need for
    #CustomBuildAction: 1, c:\windows\system32\attrib.exe, +r res\*.* /s

    Attached Files:

  3. DonManfred

    DonManfred Expert Licensed User

    #AdditionalRes: ../resources
    can be perfectly used in Buildconfigurations to set a special resource-folder for each buildconfiguration...
    #If debug
            #AdditionalRes: ../resources
    #end if
    #If french
            #AdditionalRes: ../
    #end if
    No need to set readonly on all files in resources and! :)
  4. itgirl

    itgirl Active Member Licensed User

    thank you so much for this , infact i didn't know that we can use AdditionalRes to replace the actual res
    Peter Simpson likes this.
  5. itgirl

    itgirl Active Member Licensed User

    but let's say i have values and values-fr AdditionalRes will be using the values accordingly right ?
  6. DonManfred

    DonManfred Expert Licensed User

    if you have values and values-fr it will work like if you had this files in objects/res
    Just try it, girl :)
    Peter Simpson likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice