I created New Android Studio Project including Kotlin support and when the project build finished I got two errors at very beginning of the MainActivity as follows,
- Package Name Error: Package directive doesn’t match file location
- In onCreate at line setContentView(R.layout.activity_main) : Unresolved reference: R
I did followed all the setup steps according to the Android Studio 3.0 Canary setup docs.
The R problem could be resolved by compiling the app as the R file is generated and doesn’t actually exist before compilation. While android studio often simulates its generation sometimes this breaks (often because of resource issues). The package name error should have a quick fix for it, but if that is in a Kotlin file it should be a warning, not error.
Hi there,
I couldn’t solve the R problem. Ubuntu/Android Studio Canary 3.0 9
Which are the steps to fix it?
Thanks in advanced.
Best regards,
Abelardo.
I got the same Error also but before this my application are working fine. I dont know what happend.How can i solve this problem?
I had the same problem. And the solution was to make the rebuild of the project.
Solution:
- Click build and then rebuild project.