Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 412
DanKCl Avatar asked Nov 20 '14 15:11

DanKCl


1 Answers

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.

like image 127
IgorGanapolsky Avatar answered Nov 18 '22 16:11

IgorGanapolsky