Some of you may have noticed that AndroidStudio really wants you to develop for Lollipop–so much so that if you try to create a new project for any of the 4.x versions, it will be broken out of the box. Now, I’m not sure how widespread this problem is, so as a disclaimer, I’ll say I have this problem every time, with the most up-to-date version of AndroidStudio from the Beta channel, on my machine. Here’s some relevant system configuration data:
- Mac OS X 10.8.5
- AndroidStudio 1.1.0
- javac 1.6.0_65
- Android SDK Build Tools 21.1.2 (with a few older versions still installed)
The problem arrises when I go to create a new project for ICS 4.0.3 (API level 15). I select a Blank Activity, which is just about the simplest project template possible, and complete the setup. Without any after-the-fact changes on my part, this project will fail to build, citing numerous issues. Here’s what I have to do (every time I start a project) to get the thing building:
- Project Structure / Module Settings (select app node, CMD+DownArrow):
- Properties Tab
- Set correct compile SDK
- Set source and target compatibility to 1.6
- Flavors Tab
- Set min and target SDK versions to appropriate values
- Dependencies Tab
- Delete the entry for the android compatibility library it tries to foist on you
- Properties Tab
- manifests/AndroidManifest.xml:
- Delete the
"android:theme"
attribute from<application>
tag
- Delete the
- res:
- Delete values/styles.xml
- Rename
<item>
attrib"app:showAsAction"
=>"android:showAsAction"
in all your menu/menu_xxx.xml files
- FooActivity.java:
- Make all your Activities extend
Activity
rather thanActionBarActivity
(which is from the compat library)
- Make all your Activities extend
- Rebuild Your Project
- Run, Confirm You See “Hello World”
- Done!
Hope someone else finds this useful. If you can shed some light on this issue or know a more permanent workaround, I’d love to hear about it in the comments or on Twitter.