I added a translation to the strings.xml
file so now I have 2 strings.xml
files, one in hebrew and one in english (the original).
After I did that, suddenly in the MainActivity.java
file, every time there's R
in the code, it shows in red color and says
Cannot resolve symbol 'R'
I tried all answers in other posts and it didn't help:
- I tried cleaning the Gradle and sync it.
- There are no xml errors
- After adding
import android.R;
the error disappears but now the same error is shown for all xml file names (for exampletoastText = getString(R.string.negativeCups);
,negativeCups
is in red and shows this error. - I tried restarting Android Studio
- I tried adding
import com.howtoevery.justjava.R;
- There are no files named with capital letters in the
Res
folder - I tried changing the
compileSdkVersion
,buildToolsVersion
andtargetSdkVersion
- I tried adding
import android.R.*
and generally, I tried every answer in this post but nothing worked for me.
The code for the original strings.xml
file:
<resources>
<string name="app_name" translatable="false">Just Java</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="quantity">Quantity</string>
<string name="order">Order</string>
<string name="add">Add another cup of coffee to your purchase</string>
<string name="reset">Reset calculation</string>
<string name="decrease">remove 1 cup</string>
<string name="ordering">You are going to order</string>
<string name="ordering_cups_price">cups of coffee at a price of</string>
<string name="empty_order">You can't order nothing, please buy at least 1 cup of coffee</string>
<string name="resetted">Cups of coffee is already reset.</string>
<string name="negativeCups">You can't have negative number of cups of coffee</string>
</resources>
The code for the translation:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="add">תוסיף עוד כוס קפה להזמנה</string>
<string name="decrease">תסיר כוס אחת</string>
<string name="hello_world">שלום עולם!</string>
<string name="order">הזמן!</string>
<string name="quantity">כמות</string>
<string name="reset">אפס כמות</string>
<string name="action_settings">הגדרות</string>
<string name="ordering">אתה עומד להזמין</string>
<string name="ordering_cups_price"> כוסות קפה במחיר של </string>
<string name="empty_order">מה אתה פסיכי? אי אפשר להזמין כלום</string>
<string name="resetted">משעמם לך? לחצת כבר איפוס יא חופר</string>
<string name="negativeCups">טוב מה נהיה?? אתה רוצה כבר למכור כוסות?</string>
</resources>
Update:
I even deleted the folder with the file of the localized strings.xml
and still I have the same problem.