【发布时间】:2019-11-22 06:19:35
【问题描述】:
我有一个片段:
class SomeFragment {
private val args by navArgs<SomeFragmentArgs>()
}
这个片段用在两个导航图中:
first_nav.xml
....
<fragment
android:id="@+id/initialFragment"
android:name="com.example.InitialFragment"
android:label="Initial Fragment">
<action
android:id="@+id/action_to_some_fragment"
app:destination="@id/someFragment" />
</fragment>
<fragment
android:id="@+id/someFragment"
android:name="com.example.SomeFragment"
android:label="Some Label">
<argument
android:name="someType"
app:argType="com.example.someType"/>
</fragment>
....
second_nav.xml
....
<fragment
android:id="@+id/initialFragment2"
android:name="com.example.InitialFragment2"
android:label="Initial Fragment">
<action
android:id="@+id/action_to_some_fragment"
app:destination="@id/someFragment" />
</fragment>
<fragment
android:id="@+id/someFragment"
android:name="com.example.SomeFragment"
android:label="Some Label">
<argument
android:name="someType"
app:argType="com.example.someType"/>
</fragment>
....
但是当我为发布 R8 构建项目时:
R8:程序类型已存在:com.example.SomeFragmentArgs$Companion
谁能帮我解决这个问题?
【问题讨论】:
-
您使用的是哪个版本的导航组件?
-
您在不同图表中的片段具有相同的 id,即使认为它不会相互冲突,因此生成的类将是相同的。因此,在两个图中尝试不同的参数名称(即 firstNavSomeType 和 secondNavSomeType),问题可能会在重建项目时得到解决。
-
我使用的是 2.1.0。我相信那是最新版本。
-
他们的事情是,它只会在发布/签名时抛出这个错误。在调试中构建项目时,它很好。但我会尝试你的建议。
-
你有什么进展吗?我也有同样的问题
标签: android android-architecture-navigation android-safe-args