Android Question Variable 'label_name' was not initialized. (warning #11)

Alessandro71

Active Member
Licensed User
I have several labels defined in the same .bal layout file.
All of them are declared in the same activity, like:

B4X:
Private Lbl_EOT_TemplateCont As Label
Private Lbl_EOT_Logo As Label
Private Lbl_EOT_DateCont As Label

but only one of them, namely Lbl_EOT_Logo gets flagged in the above lines with the error:

Variable 'Lbl_EOT_Logo' was not initialized. (warning #11)

Project compiles fine and runs with no issues: label is perfectly working (in this case it's a BitmapDrawable)
 

DonManfred

Expert
Licensed User
Longtime User
Hard to help without seeing your project or at least all relevant code.
Try to reproduce it in a small project and upload this project.
 
Upvote 0

Alessandro71

Active Member
Licensed User
that's an interesting test
since project is really big, i tried stripping everything to have a minimal project, and the error goes away...
now the hard part: which seemingly unrelated code affects this one?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Do you have a second instance of Lbl_EOT_Logo anywhere in your code as a local Label variable, a sub or a module maybe?
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
On the odd occasion , I have had a similar problem.

Deleting the view from Designer and saving layout, and any global declaration and saving project .. then recreating the view
seemed to solve this.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
This may happen when you add the declaration in the code before adding or naming the view in the Designer.
Is the spelling OK?
When you change the name in the Designer without pressing Return, this can happen too.
 
Upvote 0

Alessandro71

Active Member
Licensed User
On the odd occasion , I have had a similar problem.

Deleting the view from Designer and saving layout, and any global declaration and saving project .. then recreating the view
seemed to solve this.

negative
i've even tried changing order of both declaration and views in designer
 
Upvote 0

Alessandro71

Active Member
Licensed User
This may happen when you add the declaration in the code before adding or naming the view in the Designer.
Is the spelling OK?
When you change the name in the Designer without pressing Return, this can happen too.
negative
i've renamed it, recreated it, without any different outcome
if i find all references (F7) it's correctly found in the designer layout file

same with 2 other labels in 2 different .bal files
 
Upvote 0

malcolm_FM4E

New Member
Hi I just resolved the same problem by using [Tools] - [Generate Members] in the Visual Designer and selecting the variables and clicking [Generate Members]. HTH.
 
Upvote 0
Top