jcw
jcw

Reputation: 5162

Constructor refers to missing type context

I have written a class with the following constructor

public CustomDialog(Context context)

But when I try to do this in my activity

CustomDialog diag = new CustomDialog(getApplicationContext()){/*stuff here*/};

I get the error The constructor CustomDialog(Context) refers to the missing type Context

What does this mean? And how do I fix it?

Upvotes: 3

Views: 17867

Answers (6)

Mohandas Rajendran
Mohandas Rajendran

Reputation: 1

Project->Clean worked for me.

Upvotes: -1

vnxyz
vnxyz

Reputation: 466

Did a maven update on the project, it worked for me.

Upvotes: 0

arm32x
arm32x

Reputation: 147

I fixed it by adding some code and then removing it again. For example, add an empty statement and then remove it. Eclipse should check for errors again and not find your error.

Upvotes: 0

vovahost
vovahost

Reputation: 35997

First you should fix all other errors in your code than you should repeat Project -> Clean in Eclipse to see if the error was fixed.

Upvotes: 5

JstnPwll
JstnPwll

Reputation: 8685

In case anyone else had this issue: I had the same problem with some code that called a method from the Play Licensing library. I fixed it by using Project > Clean on Play Licensing project (as opposed to the project where the error was showing up).

Upvotes: 7

CommonsWare
CommonsWare

Reputation: 1006554

What does this mean?

AFAIK, either:

  • You are missing the import android.content.Context, or

  • Your project is messed up, and the compiler cannot find android.content.Context in your build path

Upvotes: 5

Related Questions