Preface
Someone asked this afternoon where to configure AS, thus achieving the default compileSdkVersion when creating a new module with the specified value instead of taking the API-string of the latest SDK.
Solution
I looked at Preferences first, and there is no relevant template that can be modified, Google for a while, onlyThis postMentioned
location of template file.
Follow the given path<android-studio>/plugins/android/lib/templates/gradle-projects/NewAndroidProject/root/ (on Mac <android-studio>
That is/Applications/Android\ /Contents)
Find the template file.
Find compileSdkVersion directly
compileSdkVersion <#if buildApiString?matches("^\\d+$")>${buildApiString}<#else>'${buildApiString}'</#if>
Change to
compileSdkVersion 24
This is done.
Extra minor questions
We know that the support appcompat package will be added when creating a new phone module in AS. Since the error prompt will appear if the large version of the appcompat package is different from compileSdkVersion, the default version of appcompat also needs to be modified.
But the template file corresponding to appcompat is not presentIn, but in
<android-studio>/plugins/android/lib/templates/gradle-projects/NewAndroidProject/
middle.
The corresponding code is
<#if backwardsCompatibility!true> <dependency mavenUrl=":appcompat-v7:${buildApi}.+"/> </#if>
Modify directly to
<dependency mavenUrl=":appcompat-v7:24.+"/>
The job is done ~
Make complaints
Generally, there will be no such weird demands. If you encounter them... well, this is the only solution for the time being. It should be noted that conflicts may occur when AS is updated and the modified files are overwritten with a new template file, so it has to be processed again, which is a bit troublesome.
Summarize
The above is the entire content of this article. I hope the content of this article will be of some help to all Android developers. If you have any questions, you can leave a message to communicate. Thank you for your support.