相关疑难解决方法(0)

无法解析库模块中的Kotlin Android Extension布局

我有我的buyer,seller模块和common模块.两个buyerseller模块中使用的布局很少放在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"
Run Code Online (Sandbox Code Playgroud)

在IDE中一切正常

  1. 我的布局预览通过在IDE的布局预览中解析include标记和膨胀来正确显示.
  2. 我的kotlin文件也正确地解析了工具栏引用,并没有显示任何问题.

但每当我尝试构建应用程序时,它会给我编译错误:

Unresolved reference: toolbar <-- Id of the toolbar inside layout_toolbar.xml
Run Code Online (Sandbox Code Playgroud)

如果IDE可以正确解析依赖关系,为什么不能构建gradle?有什么我做错了吗?

请注意,common模块与implementation其他两个模块一样添加.但我尝试 …

android gradle kotlin kotlin-android-extensions

15
推荐指数
1
解决办法
1388
查看次数