Cha*_*har 15 android gradle kotlin kotlin-android-extensions
我有我的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"
Run Code Online (Sandbox Code Playgroud)
在IDE中一切正常
但每当我尝试构建应用程序时,它会给我编译错误:
Unresolved reference: toolbar <-- Id of the toolbar inside layout_toolbar.xml
Run Code Online (Sandbox Code Playgroud)
如果IDE可以正确解析依赖关系,为什么不能构建gradle?有什么我做错了吗?
请注意,common模块与implementation其他两个模块一样添加.但我尝试api过也不行.
乍一看,这似乎是一个好问题。我在当前的项目中重现了同样的问题。
我已经通过添加了库模块
实施项目(':mylibrary')
在项目中添加了库模块。
最后,我能够以编程方式更改它。
导入 kotlinx.android.synthetic.main.activity_home.* 导入 kotlinx.android.synthetic.main.item_library.*
构建环境可能存在一些问题。注意:我使用的是最新的构建版本以及 android 和 kotlin 插件。
请更新您的日志以进一步澄清您的问题。
| 归档时间: |
|
| 查看次数: |
1388 次 |
| 最近记录: |