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

1k Views Asked by At

I would like to use SugarOrm in my app.

If I add the followings:

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

to the gradle file

and

 android:name="com.orm.SugarApp"

to my mainfest's application name

I get the following error on build:

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

at this line:

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

If I checkout to a previous version without these 2 lines, my application builds and runds without error.

Any suggestions?

2

There are 2 best solutions below

0
Adam Varhegyi On BEST ANSWER

I have updated to compile 'com.github.satyan:sugar:1.6' and error is gone.

0
Ivan Alburquerque On

From the Android Documentation:

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

Do you really need that backward compatibility? Try accesing getColor from the context. You can also still useContext.getColor() while you resolve the main issue however