How to modify the default compilesdkversion when Android studio creates a module

preface

This afternoon, someone asked where the as can configure the build.gradle template to achieve the default compilesdkversion when creating a new module, using the specified value instead of the API string of the latest SDK.

Solution

After reading the preferences, no relevant template can modify build.gradle, and then Google for a while. Only this post mentioned the location of the template file of build.gradle.

Find the template file according to the given path < Android studio > / plugins / Android / lib / templates / gradle projects / newandroidproject / root / build.gradle.ftl (on MAC, < Android studio > is / applications / Android \ studio. App / contents).

Directly find the line compilesdkversion

Change to

So it's done.

Additional minor problems

We know that when as creates a new phone module, it will add the support appcompat package. Since the error prompt will appear if the large version of appcompat package is different from compilesdkversion, you also need to modify the default version of appcompat.

However, the template file corresponding to appcompat is not in build.gradle.ftl, but in < Android studio > / plugins / Android / lib / templates / gradle projects / newandroidproject / recipe.xml.ftl.

The corresponding code is

Directly modify to

It's done~

Make complaints

Generally, there is no such wonderful demand. If you encounter... Well, this is the only solution for the time being. It should be noted that conflicts may occur when the as is updated, and the modified file may be overwritten with the new template file, so it needs to be processed again, which is a little troublesome.

summary

The above is the whole content of this article. I hope the content of this article can bring some help to Android developers. If you have any questions, you can leave a message. Thank you for your support for programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>