I tried creating my first app in android, wherein i tried putting a simple button. After following a step by step procedure of ‘how to do it’ from http://developer.android.com/training/basics/firstapp/building-ui.html i found that there are unresolved errors in the activity_main.xml file in the following line:
android:text=”@string/scan” />
The error says error: Error: No resource found that matches the given name (at ‘text’ with value ‘@string/scan’).
Can anyone tell me why and also explain how i can solve this?
I am pasting the whole xml file contents here:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/scan" />
</LinearLayout>
Here are the contents of sting.xml
<resources>
<string name="app_name">Myaxx</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
</resources>
Here are the contents of the activity_main file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_scan" />
</LinearLayout>
The error says that you do not have a string with name scan in your strings.xml file.
do you have a string with name scan in your strings.xml?
If not try adding a string in strings.xml
simply do this
This means that you are having a string with name scan and value scan (In the last scenario) and you are referring it using @string/scan which returns the value of the string with name scan (@string/nameOfTheString)