2

I'm making an Android app using appcompat using com.android.support:appcompat-v7:23.0.3 and getting following error.

Error:(22, 9) error: method setSupportActionBar in class AppCompatActivity cannot be applied to given types; required: android.support.v7.widget.Toolbar found: android.widget.Toolbar reason: actual argument android.widget.Toolbar cannot be converted to android.support.v7.widget.Toolbar by method invocation conversion

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Swarathesh Addanki
  • 431
  • 1
  • 6
  • 17

6 Answers6

7

First of all appcompat 23.0.3 doesn't exist.

Use 23.0.1

com.android.support:appcompat-v7:23.0.1

Then the method setSupportActionBar works with android.support.v7.widget.Toolbar.

Check the import in your code.
When you are using the Toolbar,you have to use the right import:

import android.support.v7.widget.Toolbar;

Finally also in your layout, you have to use the right widget.

<android.support.v7.widget.Toolbar
    ..... />
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
3

I have problem same with you

I change extends Activity to extends ActionBarActivity

Like this:

public class myclass extends Activity

to

public class myclass extends ActionBarActivity
Abed Putra
  • 1,153
  • 2
  • 17
  • 37
2

Change android.widget.Toolbar import statement to android.support.v7.widget.Toolbar

import android.support.v7.widget.Toolbar;
Aryan Najafi
  • 2,496
  • 27
  • 29
0

Forget ToolBar New solution to change Name of Activities is here Use Manifests &

android:label="name_to_be_changed"

for ex.

`<enter code hereactivity android:name=".MyActivity"
android:label="My Activity"
android:screenOrientation="portrait"/>`
Rushabh Gedam
  • 310
  • 1
  • 4
  • 11
0

I also faced the same problem while adding toolbar widget. In my case, I have changed import link to : android.support.v7.widget.Toolbar;

and it worked fine.

Kazi
  • 1
-1

just import android.support.v7.widget.Toolbar, import android.support.v7.app.AppCompatActivity, and make sure that your xml file tool bar contain same like this after that extend the class AppCompatActivity i think this solve your problem