问题描述
首先,我所知道的this题;不过,我可以不遵守的答案,因为没有提到有目录。
First of all, I'm aware of this question; however I cannot follow the answer because there are no directories mentioned there.
在创建新的Android Studio项目我想自动创建以下内容:
When creating new Android Studio project I want the following to be created automatically:
- 针对包和目录;
- 摇篮依赖
- 若干类(可能是从别的地方进口)
是否有可能为这些任务的Android Studio中的模板?
Is it possible to create an Android Studio template for these tasks?
推荐答案
看看这个文件夹的Android SDK文件夹下:
Check out this folder under your android SDK folder:
android-sdk\tools\templates\projects
有如下看到过三predefined模板,我们一般使用。
There are three predefined templates as seen below, which we generally use.
每个模板文件夹中都有不同的 FTL
文件,这是每个现有项目的模板:
Each template folder has different ftl
files which are templates for each of the existing projects:
您可以创建一个新的模板文件夹,当你希望他们设计了 FTL
文件。还定义项目的结构。
You can create a new template folder and design the ftl
files as you want them to. And also define project structures.
只需打开其中的一个,你会得到的默认模板如何有一个想法。扩展这些或只要你想从头开始创建你自己的。
Just open one of these and you'll get an idea of how the default templates are there. Extend those or create your own from scratch as you want.
有了上面说,你的问题都可以回答如下:的
With the above said, your questions can be answered as follows:
创建软件包在根创建文件夹结构
文件夹来匹配你的包名。
For creating packages create a folder structure in the root
folder to match your package name.
的Gradle对于依赖将它们添加到您的 *。gradle.ftl
文件,按要求。
For gradle dependencies add them to your *.gradle.ftl
files, as required.
对于复制/导入退出类/文件看看 recipe.xml.ftl
来得到如何复制的想法。
For copying/importing exiting classes/files look at recipe.xml.ftl
to get an idea of how to copy.
更新:经过群众举报,如果在上面提到的文件夹改变的Android SDK下它不能工作
我再次搜查,发现当这些模板存储即另一个位置直属的Android Studio安装文件夹并没有在Android SDK文件夹。
I searched again and found another location where these templates are stored i.e. directly under the Android Studio installation folder and not the Android SDK folder.
验证,的Android Studio版本1.5
&安培; Android的Studio版本2.0 Beta版
:
<installation folder>\plugins\android\lib\templates
如前所述它们的文件类型和组织是一样的。
The file types and organization of them is same as mentioned earlier.
这篇关于Android的Studio中创建新项目的项目模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!