Android Studio 为新项目创建项目模板 [英] Android Studio create project template for new projects

查看:53
本文介绍了Android Studio 为新项目创建项目模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我知道

我们通常使用的三个预定义模板如下所示.

每个模板文件夹都有不同的 ftl 文件,这些文件是每个现有项目的模板:

您可以创建一个新的模板文件夹并根据需要设计ftl 文件.并定义项目结构.

只需打开其中一个,您就会了解默认模板是如何存在的.根据需要扩展这些或从头开始创建自己的.

综上所述,您的问题可以回答如下:

用于创建包root 文件夹中创建一个文件夹结构以匹配您的包名称.

对于 gradle 依赖项,根据需要将它们添加到您的 *.gradle.ftl 文件中.

要复制/导入现有的类/文件,请查看 recipe.xml.ftl 以了解如何复制.

<小时><小时><小时><块引用>

更新:在人们报告说如果在 Android SDK 下的上述文件夹中更改则无法正常工作后

我再次搜索并找到了存储这些模板的另一个位置,即直接在 Android Studio 安装文件夹下,而不是 Android SDK 文件夹.

已针对 Android Studio 1.5 版 进行验证 &Android Studio 2.0 测试版:

<安装文件夹>\plugins\android\lib\templates

它们的文件类型和组织与前面提到的相同.

First of all, I'm aware of this question; however I cannot follow the answer because there are no directories mentioned there.

When creating new Android Studio project I want the following to be created automatically:

  1. Specific packages and directories;
  2. Gradle dependencies
  3. Several classes (might be imported from somewhere else)

Is it possible to create an Android Studio template for these tasks?

解决方案

Check out this folder under your android SDK folder:

android-sdk\tools\templates\projects

There are three predefined templates as seen below, which we generally use.

Each template folder has different ftl files which are templates for each of the existing projects:

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.

For gradle dependencies add them to your *.gradle.ftl files, as required.

For copying/importing exiting classes/files look at recipe.xml.ftl to get an idea of how to copy.




UPDATE: After people reported it not to be working if changed in the above mentioned folder under 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.

Verified for Android Studio Version 1.5 & Android Studio Version 2.0 Beta:

<installation folder>\plugins\android\lib\templates

The file types and organization of them is same as mentioned earlier.

这篇关于Android Studio 为新项目创建项目模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆