DanKCl
DanKCl

Reputation: 389

android.support.v7.widget.Toolbar in Eclipse could not be instantiated

I'm new to android programming. Here is the issue I'm facing:-

I followed the xml code for toolbar from http://android-developers.blogspot.com/2014/10/appcompat-v21-material-design-for-pre.html and applied into Eclipse. I received this message:

"The following classes could not be instantiated: - android.support.v7.widget.Toolbar (Open Class, Show Error Log) See the Error Log (Window > Show View) for more details."

May I ask any idea how to solve this issue? Thanks!

Upvotes: 8

Views: 5802

Answers (1)

IgorGanapolsky
IgorGanapolsky

Reputation: 26821

If you are targeting Android 22, then make your MainActivity extend from AppCompatActivity instead of ActionBarActivity. Then rebuild your gradle project and voila!

The only other possible solution I found is to switch SDK version to 21 in the upper-right (green android guy) of the Preview window.

Upvotes: 1

Related Questions