error: cannot find symbol method getColor(Context,int) after adding Sugar ORM to project

error: cannot find symbol method getColor(Context,int) after adding Sugar ORM to project

我想在我的应用程序中使用 SugarOrm。

如果我添加以下内容:

 compile 'com.github.satyan:sugar:1.4'

到 gradle 文件

 android:name="com.orm.SugarApp"

到我的 mainfest 的应用程序名称

我在构建时遇到以下错误:

Error:(75, 55) error: cannot find symbol method getColor(Context,int)

在这一行:

 holder.bg.setBackgroundColor(ContextCompat.getColor(ctx, R.color.primary_move));

如果我在没有这两行的情况下检出到以前的版本,我的应用程序可以正确构建和运行。

有什么建议吗?

来自Android Documentation

Helper for accessing features in Context introduced after API level 4 in a backwards compatible fashion.

你真的需要向后兼容吗?尝试从上下文访问 getColor。您也可以在解决主要问题时仍然使用Context.getColor(),但是

我已经更新编译 'com.github.satyan:sugar:1.6' 错误消失了。