Reputation: 1831
When my "ExampleAdapter" class is in the sample package as my MainActivity, I don't get an error. Let's say my MainActivity is in "com.example". When I create a new package inside of the "com.example" package (let's say "com.example.adapters"), and move my "ExampleAdapter" to the new package, I get the dreaded error, "Cannot resolve symbol 'R'". Why does it matter which package my adapter is in?
Upvotes: 0
Views: 456
Reputation: 1007369
Why does it matter which package my adapter is in?
The R
and BuildConfig
classes are always code-generated into the Java package that you name in the package
attribute of your <manifest>
element in your AndroidManifest.xml
file. Any Java classes outside of that package that need to refer to R
or BuildConfig
need to add the corresponding import
statement, as with any other Java class from a foreign package.
Upvotes: 1