Android Question CustomBuildAction is it reliable ?

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

B4X:
#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:

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
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    '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
B4X:
#CustomBuildAction: 1, c:\windows\system32\attrib.exe, +r res\*.* /s
anymore
 

Attachments

DonManfred

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

itgirl

Active Member
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
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    '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
B4X:
#CustomBuildAction: 1, c:\windows\system32\attrib.exe, +r res\*.* /s
anymore
thank you so much for this , infact i didn't know that we can use AdditionalRes to replace the actual res
 

itgirl

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

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