Error: Cannot find symbol

Error:
[mkdir] Created dir: /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] Compiling 332 source files to /projects/goldv2/appinventor-sources/appinventor/components/build/classes/AndroidRuntime
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.7
[javac] /projects/goldv2/appinventor-sources/appinventor/components/src/com/appybuilder/sohamtshah2005/Datepicker/Datepicker.java:149: error: cannot find symbol
[javac] title.Text(String.join(Dates.MonthName(instant)," ", String.valueOf(Dates.Year(instant))));
[javac] ^
[javac] symbol: method Text(String)
[javac] location: variable title of type Component
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 1 error
[javac] 1 warning
Code:

Create(hv2,"Label","title");
title = COMPONENTS.get("title");
title.Text(String.join(Dates.MonthName(instant)," ", String.valueOf(Dates.Year(instant))));

Im using @yusufcihan dynamic components extension code to create a label

Try importing this, maybe it can work.. : -

com.google.appinventor.components.runtime.Label;

I havw imported
com.google.appinventor.components.runtime* or whatever the name is so wouldn't it be enough?

Are you trying in this/similar way : -

MyLabel = new Label(this);
MyLabel.Text("Text for Label1");

Yes just the difference is creating label by using dynamic components code, and i have tested it the component is created, just the probelm is when im trying to join monthname with year for text property

The error is that the compiler can't find the symbol Text in the type of title, which it believes is Component. You'll need to either specify that title is of some other type, such as Label, or you need to downcast to an appropriate type, such as ((Label) title).Text(...).

6 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.