Not able to find the R file in Android project - android

I am creating an Android app and while extracting the String resources for all the Strings, I am getting an error.
So I thought about it and figured out that we are getting the String by accessing the R file and when I checked app > build > generated > source >, the R file was missing. I also have checked the string.xml file and the String is also getting created over there, hence I thought the issue is with the R file.
For example, while converting the String Date of birth:
getString(R.string.dob);
It says that dob symbol is not resolvable even though I extracted its (Date of Birth) String resource and had the resource named to dob.

In the latest versions of Android Studio the following works:
Tools -> Android -> Sync Project with Gradle Files
It worked for me.

Related

R.java creating illegal value

In my R.java file I am getting error on this line
public static final int =0x7f08000a;
I have not modified the R.java. Please advice.
R.java displays error without changing in it, may be issue with your resources. Resources file's name must not contain -, capital letter of file name, try to check it after it clean the project and try to build, thanks.

Android NDK Eclipse CDT won't allow me to use substr method of string

Even a simple code like this gives the error
string test= "hello";
string part = test.substr(2, 3);
Invalid arguments Candidates are: stlpmtx_std::basic_string,stlpmtx_std::allocator> substr(?, ?)
Even casting to size_t did not not help
string part = test.substr((size_t)2, (size_t)3);
But both pieces of code working when running it as a console application using gcc 4.6 on Linux.
But when using Androind NDK it gives me the error.
If I close the file in the editor and close Eclipse, and then open Eclipse and build the project it compiles. But if I have the file open it throws up the error.
I am using APP_STL:= stlport_static in the Application.mk make file
Yes I did include <string>
Edit: I just looked at the times of .so file, it seems to be compiling even though Eclipse is showing the errors.
I found the solution I need to have to have stlport system include folder in the Paths and Symbols section of project properties -> C/C++ General
path_To_NDK/sources/cxx-stl/system/include
I only had the
path_To_NDK/sources/cxx-stl/stlport/stlport

Resources not found exception R.string

i need to add string (from resource) to Database
<string name="variable_name">AAAAA</string>
Resources.getSystem().getString(R.string.variable_name)
I tried to: -
clean project
fix Android properties
restart Eclipse
In R file variable_name exist. Sorry for my english
Make sure that you are not importing android.R.java and
You should get like this
String str=getResources().getString(R.string.variable_name);

Android R.java Syntax error on token "int", VariableDeclaratorId expected after this token

I am getting the following constantly generating in the R.java file:
public static final class id {
public static final int =0x7f0500ae;
I have done research and it all pointing to the strings file. I have checked my strings file and there is no errors. The application is not producing errors anywhere else, its just this single line that is being generated.
Can someone please help.
I had the same issue and found it odd that my strings.xml file didn't show any errors, but was able to resolve by searching through the strings.xml file for empty string name values.
Found:
<string name="">Username</string>
Changed to:
<string name="lblUsername">Username</string>
Worked and was able to compile, hope this helps.
One or more xml files might have compilation problem. Can you check?
If you are using eclipse, sometimes the xml file or folder wont show it has error (red * icon in the file or folder.
If this is not the case then delete the R.java file and rebuild the project.
or
Clean your project and rebuild it again.

Error i R.java: "Syntax error on token 'int', VariableDeclaratorId expected after this token"

This morning when I opened up Eclipse to work on an Android project I got an error inside the R.java file.
I know what the error is, but I can't seem to grasp how to fix it ;\
The code where the error is:
public static final class string {
public static final int =0x7f040010;
public static final int app_name=0x7f040000;
As you can see, the first field doesn't have a name and that gives an error of course.
Problem is when I delete the file and it's auto generated again, the error is still there.
If I try to manually change or delete the field it doesn't help. Still an error.
Tried to restart Eclipse - no difference. Tried to clean up the project and I've tried to "fix project properties" from the Android tools menu.
Anyone? It's really annoying as I can't continue with my project. I might have to delete the project and copy the classes, xml and drawables, but I'd rather not - hate doing cumbersome work :S
The problem is most likely with the strings.xml file. When you build the project that file is compiled into the R.java resources class. So check your strings.xml file carefully and as there is most likely an issue there that is causing this compilation error.
Most probably, u have an empty string in your strings.xml
<string name=""></string>

Categories

Resources