How to add new live templates in android studio in ubuntu

Viewed 614
2 Answers

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). Then you "just" have to import it as settings.

My "template_settings.zip" contains :

  • options
  • templates
  • "IntelliJ IDEA Global Settings" file
  • "installed.txt"

In "templates" folder, you can put a file "MyAndroidLog.xml" containing :

<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:

IDE configuration directory changes The locations of user configuration directories have been changed to the following:

Windows Syntax: %APPDATA%\Google

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

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

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

Linux Syntax: ~/.config/Google/

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

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

Related