1

I faced a problem with unresolved references in automatically generated files after refactoring/tidying up my project.

What I do:

  1. Create new package project/model
  2. Move existing Accountfrom project/accoutDatabase to project/model
  3. Rebuild Project
  4. Receive Error in generated files: Unresolved Reference : Account

These unresolved references are all located in the java.generated folder and annotated with "Files under the 'build' folder are generated and should not be edited. The changes will be lost when sources are generated." Thus, manually replacing the reference is useless as the files will be newly generated when rebuilding the project.

Screenshot: Folder structure & Error

img_folder_structure_&_error

I tried the steps suggested in the following link, but they didn't help. Android Studio unresolved reference. Project compiles

Does anyone of you know how to resolve this issue and what causes the problem?

Best regards

rot8
  • 143
  • 2
  • 10
  • you tried cleaning the cache and still have this problem? – benjiii Oct 06 '20 at 08:17
  • Yes, I invalidated cache and restarted but the issue persists after the restart. I also tried first deleting .idea and .gradle before invalidating cache and restarting. – rot8 Oct 06 '20 at 08:21

1 Answers1

2

Okay, I found the error source.

When moving a class.kt into a new package package.class.kt, Android Studio automatically changed import class.kt into package.class.kt in all kotlin files.

However, Android Studio did not adapt the usages in the .xml files. In my case, the moved class appeared as a safe-arg in the navigation-graph.

The solution was adapting the appearances in the .xml file - here nav_graph - manually.

i.e. manually change app:argType="class" to app:argType="package.class"

rot8
  • 143
  • 2
  • 10