Really Blank Activity (Or, Why AppCompat Is Shoved Down Your Throat)

It seems like this question or one just like it shows up almost every day on StackOverflow nowadays. Variations on the theme include:

  • Why do I get a new appcompat_v7 directory in my Eclipse workspace every time I create a new project or activity?

  • Why is it adding appcompat_v7 to my project anyway?

  • How do I get rid of this extra stuff that’s getting generated in my project?

  • HOW DO I MAKE IT STOP???!?

The issue is that the activity templates in Eclipse’s ADT — or at least BlankActivity, as I have not bothered with the others very recently — are set up to have you use ActionBarActivity and appcompat_v7. Technically, creating a project via the new-project wizard does not add appcompat_v7, but creating an activity via the new-activity wizard does. This includes checking the “create activity” checkbox in the new-project wizard, which effectively chains to the new-activity wizard.

There are two major solutions to this at this time, besides learning to love appcompat_v7:

  1. Stop using the ADT wizards to create activities.

  2. Install an activity template that does not use appcompat_v7.

Buried in the SDK source code repo lies documentation on creating ADT templates. Given all the development work on Android Studio, how well or for how long this template format will be honored is anyone’s guess. And, AFAICT, they didn’t actually bother documenting how to install these things (hint: you wind up with directories like extras/templates/activities in your SDK installation).

But they are a solution.

For example, Jeff Gilfelt’s template library has seven total templates, including five for activities, none of which will install appcompat_v7.

And I just tossed together a “Really Blank Activity” template. As the name suggests, the template generates an activity that is pretty darn blank, with just a simple “Hello, world” layout resource. No menu resources, no fragments, no libraries, no cruft.

With luck, a template like this one will ship with some future update to the ADT. Otherwise, you’re welcome to give mine a try.


Find out about new posts on the CommonsBlog via the Atom feed, or follow @CommonsWare on Twitter!