I tried to comment the junit part of the code, in gradle as well as in java. And it is working properly. But is this the only way to solve this? And why commenting the junit it is working? Why does the issue occur? Any better alternative?
Most often “R cannot be resolved” error appears if there is an issue with some of your resource files. Due to this error, you are unable to build your application. That's why we need to solve this error as it not getting away by just doing a simple restart or hitting Alt+Enter.
R is a class containing the definitions for all resources of a particular application package. It is in the namespace of the application package. For example, if you say in your manifest your package name is com. foo. bar , an R class is generated with the symbols of all your resources in com.
The cannot find symbol error, also found under the names of symbol not found and cannot resolve symbol , is a Java compile-time error which emerges whenever there is an identifier in the source code which the compiler is unable to work out what it refers to.
Rendering issues are caused by your designer preview using higher API level than your current android API level. Just change your android version on your designer preview into your current version depending on your Manifest.
Adjust with your current API Level. If the API level isn't in the list, you'll need to install it via the SDK Manager.
And for the "Cannot resolve symbol R" error, A simple 'gradlew clean' and 'gradlew build' will do the trick.
Click on Build->Clean Project and that will perform a gradle clean operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With