And for that I've written a a solution in Stack overflow. You can also read that in this URL:.
http://stackoverflow.com/questions/34979903/android-studio-gradle-build-problems-r-cant-be-resolved/41780229#41780229.
So, come to the problem of R can not be resolved to a variable.
Why this happen:
R can not be resolved to a variable is a resource file problem, that means when we run any app, then it automatically make code for all graphical representation. Reasons of this is:- When there is an error in your .xml file and it will not show an error in that file but for this reason sometime occur R can not be resolved to a variable problem in Activity.java files...
- .Sometimes there are problem in theme choosing matters.
Solutions of R can not be resolved to a variable:
- Look, if you don't write any code in .xml file then just click rebuild or build or make project button or clean button. Your problem may be solved if you have not write any code previously.
- If you modify your xxxxx.xml layout file then look these files and I'm sure you've written some wrong code. Like theme name problem, any referencing problem of strings, dimens, colors and so on. Correct them and may be your R can't be resolved text will be solved. Obviously, after doing this click make project button or rebuild button and provably get no error..
Look in my demo case of this problem R can not be resolved to a variable.
In my styles.xml file I have written that:
<style name="MyCustomToolbar" parent="ThemeOverlay.AppCompat.Light">
<item name="colorPrimary">#5974AB</item>
</style>
And in my main layout.xml file I have written that:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
....
android:popupTheme="@style/MyCustomToolber"
>
</android.support.v7.widget.Toolbar>
Look this line of layout.xml:
android:popupTheme="@style/MyCustomToolber"
I've write some wrong name that means name mismatched..And for that reason there was a problem in my xml file of R can not be resolved to variable..
And finally if you face any problem then knock me here and I 'll answer obviously...
0 comments:
Post a Comment