简体   繁体   English

如何在 ubuntu 的 android 工作室中添加新的实时模板

[英]How to add new live templates in android studio in ubuntu

I'm using ubuntu 20.04, and I was recentlly studing the live templates in android studio我正在使用 ubuntu 20.04,最近在 android 工作室学习实时模板

but I didn't find the templates folder但我没有找到模板文件夹

I searched every where like this selusion我搜索了每一个地方,就像这种自我感觉一样

https://stackoverflow.com/a/44177549 https://stackoverflow.com/a/44177549

or this one或者这个

https://stackoverflow.com/a/51647302 https://stackoverflow.com/a/51647302

or或者

https://medium.com/gits-apps-insight/tutorial-create-your-own-template-for-android-studio-1aaa9b4cb18 https://medium.com/gits-apps-insight/tutorial-create-your-own-template-for-android-studio-1aaa9b4cb18

and many other websites, didn't find it和很多其他网站,没找到

I'm using android studio 4.1我正在使用 android 工作室 4.1

thanks for helping谢谢你的帮助

There is a workaround for it.有一个解决方法。 Instead of copy/paste files in expected directory, you can export from previous android studio version (or create a "settings file" manually).您可以从以前的 android 工作室版本导出(或手动创建“设置文件”),而不是在预期目录中复制/粘贴文件。 Then you "just" have to import it as settings.然后你“只是”必须将它作为设置导入。

My "template_settings.zip" contains:我的“template_settings.zip”包含:

  • options选项
  • templates模板
  • "IntelliJ IDEA Global Settings" file “IntelliJ IDEA 全局设置”文件
  • "installed.txt" “安装的.txt”

In "templates" folder, you can put a file "MyAndroidLog.xml" containing:在“模板”文件夹中,您可以放置一个文件“MyAndroidLog.xml”,其中包含:

<templateSet group="MyAndroidLog">
  <template name="loguw" value="LogUtils.w(BuildConfig.DEBUG, LOG_TAG, &quot;$METHOD_NAME$: $content$&quot;);" description="Custom Log.w(TAG, String) with LogUtils" toReformat="true" toShortenFQNames="true">
    <variable name="METHOD_NAME" expression="methodName()" defaultValue="" alwaysStopAt="false" />
    <variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
    </context>
  </template>
</templateSet>

Please tell me if it is not clear enough !请告诉我是否不够清楚!

For android studio 4.1 I found the live templates XML in this below path:对于 android studio 4.1,我在以下路径中找到了实时模板 XML:

IDE configuration directory changes The locations of user configuration directories have been changed to the following: IDE 配置目录变更 用户配置目录位置变更如下:

Windows Syntax: %APPDATA%\Google Windows 语法:%APPDATA%\Google

Example: C:\Users\YourUserName\AppData\Roaming\Google\AndroidStudio4.1示例:C:\Users\YourUserName\AppData\Roaming\Google\AndroidStudio4.1

macOS Syntax: ~/Library/Application Support/Google/ macOS 语法:~/Library/Application Support/Google/

Example: ~/Library/Application Support/Google/AndroidStudio4.1示例:~/Library/Application Support/Google/AndroidStudio4.1

Linux Syntax: ~/.config/Google/ Linux 语法:~/.config/Google/

Example: ~/.config/Google/AndroidStudio4.1示例:~/.config/Google/AndroidStudio4.1

C:\Users\YourUserName\AppData\Roaming\Google\AndroidStudio4.1\templates C:\Users\YourUserName\AppData\Roaming\Google\AndroidStudio4.1\templates

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM