Thursday, February 6, 2014

Change default minSdk for new project in Android Studio

Does somebody still set API lvl 7 as their minimum required SDK when creating a new Android Project?

Indeed.

Android 2.1 Eclair currently represents less than 0.1% according to the Android Dashboards. So why does Android Studio still selects this as the default value for Minimum required SDK version?
I've written a post last week about adding a code template for Log.d in Android Studio and I was surprised about the interest of everybody. So I've decided to write about a little tweak in Android Studio again.

It took me quite some time and searching, but I've found out how you can change this to be something else, like 14 for example. Go to the android-studio directory and follow this path: plugins/android/lib/templates/gradle-projects/NewAndroidModule/template.xml

Open the file with your favourite editor and look for a parameter-tag with id="minApi".
Change the default to 14, save the file and (re)start Android studio. Now when you choose New Project, the default value for minimum required SDK will be put at 14.

I've been searching to change the default packageName as well because I always need to change it. There's a parameter in the template.xml file as well but I'm afraid it gets overwritten by another value that's probably hard-coded. However, if you would find out how to do that, let me know ;-)

Hope this helps you out a bit!