7

I receive the error on the line below:

AlertDialog.Builder  alrtDialog = new AlertDialog.Builder(this);

The Error show is :

AlertDialog.Builder cannot be resolved to a type

I import the following for this:

import android.content.DialogInterface;

the java code in the example(from android programming unleashed) includes android.app.AlertDialog but importing this results in message: conflicts with a type defined in the same file

M D
  • 47,665
  • 9
  • 93
  • 114

4 Answers4

14

You have to import this

import android.app.AlertDialog.Builder

Timothy T.
  • 602
  • 4
  • 10
  • Grats on beating the other answers by mere minutes. In any case, what would you do if this didn't resolve the issue? I'm still getting a "can not resolve symbol" in an Android LibGDX project. – Herb Meehan May 07 '15 at 00:44
6

Try to import

import android.app.AlertDialog;

and also if your using this line AlertDialogManager alert = new AlertDialogManager(); remove it and try.

Hariharan
  • 24,741
  • 6
  • 50
  • 54
3

first check that you have import the corresponding package

import android.app.AlertDialog; and then c

check that you are using your activity instance

AlertDialog.Builder alert = new AlertDialog.Builder(yourActivityname.this);
Nambi
  • 11,944
  • 3
  • 37
  • 49
1

You must import your AlertDialog

import android.app.AlertDialog.Builder

instead of

import android.content.DialogInterface;

Also Change

AlertDialog.Builder  alrtDialog = new AlertDialog.Builder(YourActivity.this);
Piyush
  • 18,895
  • 5
  • 32
  • 63