Android Tutorial Modules Attributes

Basic4android v2.50 includes a new method for handling project and modules settings.

These settings are now set in the code itself. The menu items were removed.

SS-2012-12-31_13.38.49.png


The attributes syntax is simple. The hash sign (#) followed by the attribute name, a colon and the value.
Some attributes can appear more than once in the same module.

Different modules (activities, services, ...) support different attributes. The IDE will show a list with the supported attributes when you press on the hash key.

The project related attributes should be placed in the main activity.
Note that the #Region / #End Region directives are not required.

The attributes will be added automatically to existing projects when they are first loaded with the new version.

The purpose of this feature is to make it simpler to support new features that require advanced settings.

Project attributes (should be placed in the main activity)
  • CanInstallToExternalStorage - Whether the application can be installed to the external storage. Values: True or False
  • SupportedOrientations - Sets the supported orientations. Values (case is important): unspecified, portrait or landscape (other possible values)
  • ApplicationLabel - The application label that will appear in the applications list (string)
  • VersionName - Version name (string)
  • VersionCode - Version code. Must be an integer
  • Library compilation attributes. Covered in the library compilation tutorial
  • CustomBuildAction - See the Custom Build Actions section in this tutorial.
  • AdditionalRes - Specifies a folder with resource files. These resource files will be added to the APK. This attribute also accepts an optional parameter, the package name of an Android library project. This is required when wrapping a library that includes resource files. See this example: jfeinstein10 SlidingMenu libraryYou can use this attribute multiple times.
  • DebuggerForceFullDeployment - Forces the rapid debugger to redeploy the complete project every compilation. This can be useful if you see slow performance after modify the code. It will disable the quick redeployment feature of the rapid debugger.
    Values: True or False.
  • DebuggerForceStandardAssets - Disables the virtual assets feature of the rapid debugger. By default the rapid debugger doesn't use the standard assets folder. This allows the debugger to only redeploy updated files. Values: True or False.
  • ExcludeClasses - Can be used to strip library classes during compilation: https://www.b4x.com/android/forum/threads/new-feature-three-birds-with-one-stone.63127/

Activity attributes
  • FullScreen - Whether to show the top bar. Values: True or False
  • IncludeTitle- Whether to show the title. Values: True or False

Service attributes
  • StartAtBoot - Whether this service should start automatically after boot. Values: True or False
  • StartCommandReturnValue - (advanced) Sets the value that will be returned from onStartCommand. The default value is android.app.Service.START_NOT_STICKY. See this link for the possible values.

All modules support the following attributes:
  • ExcludeFromDebugger - Whether to exclude this module from the debugger. Debug information will not be added to this module. Values: True or False
    This attribute is only relevant to the legacy debugger.
  • IgnoreWarnings - A list of warnings numbers that will be ignored in this module.

Custom Build Actions

The build process is made of a number of steps. You can add additional steps that will run as part of the build process. For example you can run a batch file that will copy the latest resource files from some folder before the files are packed.

Another example. You can use this code to mark all files under res folder as read-only (and prevent the compiler from deleting them):
B4X:
#CustomBuildAction: 1, c:\windows\system32\attrib.exe, +r res\*.* /s

Note that you can add any number of build actions.
CustomBuildAction should be added to the main activity.
The running folder is set to the program objects folder.
The syntax is:
<step id>, <program to run>, <program arguments>

step id can be one of the following:
1 - Before the compiler cleans the objects folder (it happens after the code is parsed).
2 - Before R.java file is generated.
3 - Before the package is signed (the APK file at this point is: bin\temp.ap_).
4 - Before the APK is installed.
5 - After the APK is installed.
6 (new in v5.01) - After Java compilation.
 
Last edited:

johnaaronrose

Active Member
Licensed User
Debugger removal

I haven't used B4A in a while. But I think that there was an option in the menu to include/exclude the debugger in a project. I don't see it now. Is it a parameter to be placed in each module or is there a better way?
PS I 'm using the latest verions of B4A, namely 2.52

Please ignore this unless you are a Linux user. Problem is that Wine is not showing contents of combo boxes, in particular the one with debug & release.
 
Last edited:

CidTek

Active Member
Licensed User
I haven't used B4A in a while. But I think that there was an option in the menu to include/exclude the debugger in a project. I don't see it now. Is it a parameter to be placed in each module or is there a better way?
PS I 'm using the latest verions of B4A, namely 2.52

Please ignore this unless you are a Linux user. Problem is that Wine is not showing contents of combo boxes, in particular the one with debug & release.

There is a drop list on the IDE toolbar that offers Release or Debug options.
 

Laurent95

Active Member
Licensed User
I haven't used B4A in a while. But I think that there was an option in the menu to include/exclude the debugger in a project. I don't see it now. Is it a parameter to be placed in each module or is there a better way?
PS I 'm using the latest verions of B4A, namely 2.52

Please ignore this unless you are a Linux user. Problem is that Wine is not showing contents of combo boxes, in particular the one with debug & release.

Hi,

I don't know if you got a response about this.
But in case, you change the value of "CompileMode=X" in b4aVx.x.ini in your "C:\Users\xxxxxxx\AppData\Roaming\Anywhere Software\Basic4android" folder.
Where X is 0 in debuging mode, 1 in release mode and 2 in release obfuscated mode.

Maybe you need to update Wine also, that seems the new version work better with many windows applications.

Regards.
 

aklisiewicz

Active Member
Licensed User
Wow, that's great! :icon_clap:

1. So I can finally realize some of my ideas mentioned here:
[Wish] Plug-Ins for IDE/Compiler?

2. So an #include-directive isn't far away, is it? ;)
(Implemented directly by Erel, or by myself using #CustomBuildAction...)

3. It would by nice to have the possibility to specify dependencies (libs, other moduls), so we must not remember such things personally, e. g.:
B4X:
#libs Reflection, Phone  'check libs, if not already checked
#uses mStrings, mHelper  'adds these modules, if not already loaded

well this is really, really needed feature !
Art
 

jcesar

Active Member
Licensed User
Hi

How can i read the #VersionName value from another activity ? I need this value to show in a About activity.
 

MrKim

Well-Known Member
Licensed User
StartAtBoot and StartCommandReturnValue do not show up in my dropdown list?
 

luke2012

Well-Known Member
Licensed User
Basic4android v2.50 includes a new method for handling project and modules settings.

These settings are now set in the code itself. The menu items were removed.

SS-2012-12-31_13.38.49.png


The attributes syntax is simple. The hash sign (#) followed by the attribute name, a colon and the value.
Some attributes can appear more than once in the same module.

Different modules (activities, services, ...) support different attributes. The IDE will show a list with the supported attributes when you press on the hash key.

The project related attributes should be placed in the main activity.
Note that the #Region / #End Region directives are not required.

The attributes will be added automatically to existing projects when they are first loaded with the new version.

The purpose of this feature is to make it simpler to support new features that require advanced settings.

Project attributes (should be placed in the main activity)
  • CanInstallToExternalStorage - Whether the application can be installed to the external storage. Values: True or False
  • SupportedOrientations - Sets the supported orientations. Values (case is important): unspecified, portrait or landscape (other possible values)
  • ApplicationLabel - The application label that will appear in the applications list (string)
  • VersionName - Version name (string)
  • VersionCode - Version code. Must be an integer
  • Library compilation attributes. Covered in the library compilation tutorial
  • CustomBuildAction - See the Custom Build Actions section in this tutorial.
  • AdditionalRes - Specifies a folder with resource files. These resource files will be added to the APK. This attribute also accepts an optional parameter, the package name of an Android library project. This is required when wrapping a library that includes resource files. See this example: jfeinstein10 SlidingMenu libraryYou can use this attribute multiple times.
  • DebuggerForceFullDeployment - Forces the rapid debugger to redeploy the complete project every compilation. This can be useful if you see slow performance after modify the code. It will disable the quick redeployment feature of the rapid debugger.
    Values: True or False.
  • DebuggerForceStandardAssets - Disables the virtual assets feature of the rapid debugger. By default the rapid debugger doesn't use the standard assets folder. This allows the debugger to only redeploy updated files. Values: True or False.

Activity attributes
  • FullScreen - Whether to show the top bar. Values: True or False
  • IncludeTitle- Whether to show the title. Values: True or False

Service attributes
  • StartAtBoot - Whether this service should start automatically after boot. Values: True or False
  • StartCommandReturnValue - (advanced) Sets the value that will be returned from onStartCommand. The default value is android.app.Service.START_NOT_STICKY. See this link for the possible values.

All modules support the following attributes:
  • ExcludeFromDebugger - Whether to exclude this module from the debugger. Debug information will not be added to this module. Values: True or False
    This attribute is only relevant to the legacy debugger.
  • IgnoreWarnings - A list of warnings numbers that will be ignored in this module.

Custom Build Actions

The build process is made of a number of steps. You can add additional steps that will run as part of the build process. For example you can run a batch file that will copy the latest resource files from some folder before the files are packed.

Another example. You can use this code to mark all files under res folder as read-only (and prevent the compiler from deleting them):
B4X:
#CustomBuildAction: 1, c:\windows\system32\attrib.exe, +r res\*.* /s

Note that you can add any number of build actions.
CustomBuildAction should be added to the main activity.
The running folder is set to the program objects folder.
The syntax is:
<step id>, <program to run>, <program arguments>

step id can be one of the following:
1 - Before the compiler cleans the objects folder (it happens after the code is parsed).
2 - Before R.java file is generated.
3 - Before the package is signed (the APK file at this point is: bin\temp.ap_).
4 - Before the APK is installed.
5 - After the APK is installed.

@Erel how to knwon the module name where a Class instance is initialized ?

Ex.

The following code is inside the my class :

B4X:
CallSubDelayed2(<<< MODULE >>>, "Overflow_Click", str.Trim)

In order to allow the CallSubDelayed2 to handle the signature of the events, I have to known the module name.
 
Last edited:

Gentry

Member
Licensed User
Is there a module attribute to test and branch logic in code if the build is in debug mode? So that test cases can be easily set but not executed in Release mode? Something like

B4X:
#IfDebug {value=x}
 
Top