我有一个base
模块和一个名为的功能模块query
我的即时应用程序项目中的模块。
My QueryActivity
inside query
模块使用的颜色是base
module.
查询活动.kt https://github.com/mustafaberkaymutlu/uv-index/blob/master/query/src/main/java/net/epictimes/uvindex/query/QueryActivity.kt#L130-L135:
@ColorInt
val textColor: Int = when (resultCode) {
FetchAddressIntentService.RESULT_SUCCESS -> android.R.color.white
FetchAddressIntentService.RESULT_FAILURE -> R.color.accent // this color is inside the base module
else -> R.color.accent // this color is inside the base module
}
如果我尝试run
该项目运行良好,没有任何问题。但如果我rebuild
项目,它给了我以下错误:
../net/epictimes/uvindex/query/QueryActivity.kt
Error:(133, 63) Unresolved reference: color
Error:(134, 27) Unresolved reference: color
指向那些颜色值。
我通过添加另一个解决了这个问题colors.xml
文件内的query
模块并引用base
来自它的颜色。效果很好。你可以看到差异这次提交 https://github.com/mustafaberkaymutlu/uv-index/commit/be051af35b2edf4d3e3c6889a86e8d9258f48e75.
<color name="query_location_success_text">@android:color/white</color>
<color name="query_location_fail_text">@color/accent</color>
现在它有效,但我不知道为什么。这是正确的做法吗?我的问题是不应该是里面的资源base
可从功能模块访问模块吗?
版本:
Android 目标/编译 SDK:26
科特林:1.1.50
即时应用程序:1.1.0
这是我的一个开源项目,你可以看到整个项目here https://github.com/mustafaberkaymutlu/uv-index.
谢谢