1

I'm struggling with a really annoying problem with Safe Args in Android (Java).

I have a project structure like this:

com.myapp/
├── activites/
│   ├── ActivityA.java
|   |   ├── FragmentA1
|   │   └── FragmentA2
│   └── ActivityB.java
├── view/
|   └── ...
└── model/
    └── ...

The important part here is the package com.myapp.activities.ActivityA.

When adding some navigation paths to the nav graph, Safe Args generates the structure as following:

com.myapp/
└── activites/
    ├── ActivityA/
    |   ├── FragmentA1Directions
    │   └── FragmentA2Directions
    └── ...

In this case I cannot compile my project because I get the error

error: class ActivityA clashes with package of same name.

This makes totally sense to me as the class com.myapp.activities.ActivityA gets generated to package com.myapp.activities.ActivityA but somehow I don't understand how I should avoid this problem. Is there something completely wrong my folder structure?

woernsn
  • 11
  • 3
  • 1
    So just to clarify, your `FragmentA1` and `FragmentA2` are static inner classes of `ActivityA`? Do you see the same issue when you have them as separate classes? – ianhanniballake Oct 01 '20 at 22:40
  • Exactly. To be more precise, ActivityA is a Setting Activity and `FragmentA1` and `FragmentA2` are static `PreferenceFragmentCompat`. I did not try to move them out yet - I couldn't imagine that I am the only one facing this situation (combining Safe Args with split Preference fragments). – woernsn Oct 01 '20 at 22:47

1 Answers1

0

The usage of Fragments in an Activity seems really not to work.

I put the Fragments into separate files to make it work like suggested by @ianhanniballake.

woernsn
  • 11
  • 3