I'm using NavigationComponent
in my app and now I'm facing following problem:
I have 2 different flavors (free and paid version) which are using the same navigation.xml located in the main package. When I want to run e.g. the paid variant it failed with these errors in the generated directions file:
e: AndroidStudioProjects/foo/app/build/generated/source/navigation-args/paid/debug/de/dk/fc/ui/knowledge/KnowledgeFragmentDirections.kt: (5, 24): Unresolved reference: paid
e: AndroidStudioProjects/foo/app/build/generated/source/navigation-args/paid/debug/de/dk/fc/ui/knowledge/KnowledgeFragmentDirections.kt: (14, 41): Unresolved reference: R
Here is a snippet of my navigation.xml
<fragment
android:id="@+id/fragment_knowledge"
android:name="de.dk.fc.ui.knowledge.KnowledgeFragment"
tools:layout="@layout/fragment_knowledge">
<action
android:id="@+id/action_fragmentKnowledge_to_fragmentInfo"
app:destination="@id/fragment_info" />
</fragment>
I also added these lines of code to my build.gradle
file:
sourceSets {
getByName("main").java.srcDirs("build/generated/source/navigation-args")
}
What I've tried:
- Clean Project
- Invalidate Cache
- Duplicated navigation.xml to each flavor package
Do you have any ideas how to solve this problem?