【发布时间】:2018-10-15 04:36:51
【问题描述】:
我有我的buyer、seller 模块和一个common 模块。在buyer 和seller 模块中使用的很少布局被放置在common 模块中。
common -> layout_toolbar.xml
buyer -> activity_sell.xml ->
<LinearLayout>
<include layout="@layout/layout_toolbar" /> <!-- layout_toolbar.xml is from common module -->
</LinearLayout>
seller -> activity_buy.xml ->
<RelativeLayout>
<include layout="@layout/layout_toolbar" /> <!-- layout_toolbar.xml is from common module -->
</RelativeLayout>
buyer -> BuyActivity.kt
toolbar.title = "Buy"
seller -> SellActivity.kt
toolbar.title = "Sell"
在 IDE 中一切正常,
- 通过解析包含标记并在 IDE 的布局预览中膨胀,我的布局预览正确显示。
- 我的 kotlin 文件也正确解析了工具栏引用,并且没有显示任何问题。
但每当我尝试构建应用程序时,都会出现编译器错误:
Unresolved reference: toolbar <-- Id of the toolbar inside layout_toolbar.xml
如果IDE可以正确解决依赖关系,为什么gradle不能构建?是不是我做错了什么?
请注意common 模块在其他两个模块中添加为implementation。但我尝试过 api 也不起作用。
【问题讨论】:
-
您解决了这个问题吗?
标签: android gradle kotlin kotlin-android-extensions