Switching to Material Light Theme yeilds error

0 Kiv Sh · October 26, 2015

First timer here.
I was able to set up Android Studio fairly successfully. (had to install intel HAXM separately) 
I followed the instructions step by step and when I tried to switch to the recommended theme, I received the following (CTRL C+V) error:
The following classes could not be instantiated:
- android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache)
- android.support.design.widget.AppBarLayout (Open Class, Show Exception, Clear Cache)
 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE  
Exception Details java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library. 
  at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34)   
at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:178)   
at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:172)   
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)   
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)   
at android.view.LayoutInflater.inflate(LayoutInflater.java:385) Copy stack to clipboard  
The surrounding layout (@layout/activity_main) did not actually include this layout. Remove tools:showIn=... from the root tag

Any ideas ?

Also, I closed Android Studio, and when I relaunched it (as admin of course) the emulator was not shown...

I'm running Win 10 , if that matters.

Thank you in advance!

Post a Reply


Oldest  Newest  Rating
0 Vincent Zhu · October 30, 2015
Thanks a lot, it works for me as well. But if I would like to comment out instead of deleting the code using <! -- code --> it gives me an error. Anyone know how to do it?
0 najwa mat isa · October 30, 2015
why did my emulator takes so much time to boot?..

i am using win 10. before i used win 8 i had no such problems
0 Panduka Weerasekara · October 28, 2015
thanks a lot now the theme is working perfectly, i have removed tools:showIn="@layout/activity_main" from content_main.xml.
thanks again.
0 Aaron Chan · October 28, 2015
I did what Jing Chai said and it works. But I am still missing the menu button (three dots) in the action bar.

Also how come there is a content_main.xml and activity_main.xml now?

Before I just had activity_mail.xml.

I am currently doing the "Android App Development for Beginners - 33 - Overflow Menu"

0 Jing Chai · October 28, 2015
I fixed it by going into /app/res/content_main.xml and removing the following xml property from the <RelativeLayout /> tag:


I also did other stuff before trying this step so let me know if that doesn't work for you. 
0 Anshul Sasan · October 26, 2015
I was facing the same oroblem, so what I did instead of choosing a BLANK ACTIVITY choose  EMPTY ACTIVITY and everything should work fine
0 Panduka Weerasekara · October 26, 2015
I m having the same problem.  When I change the theme it gives the same error. 
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator