I’m getting R cannot be resolved error.
I read R cannot be resolved – Android error. But there android.R file.
My project compiles if .java files contain import com.companyname.productname.R statement.
If I change my productname in AndroidManifest.xml there’s many errors saying package com.companyname.productname does not exist.
I tried to remove all import com.companyname.productname.R lines, but then I got package R does not exist errors on lines with R.*. How can I work around this? Thanks.
Update:
So answer is yes, I must import com.companyname.productname.R. I managed to compile project after changing productname in AndroidManifest and find-and-replace all import com.companyname.productname.R statements with new productname.
You custom R class is generated based on the package name in your AndroidManifest. So if you change it there, it will be newly generated with the new package name.
Therefore make sure that you import the correct one and remove all old imports.
If you R class is not generated, you should check the for XML errors in your resource files and/or your AndroidManifest. Fix the issues there and your R file should be generated again.