Home » Android » Android Studio live template not working

Android Studio live template not working

Posted by: admin June 15, 2020 Leave a comment

Questions:

I’ve created a Live Template under the “user” template group. I’ve set the Abbreviation to “setpref”. It is listed on my list of Live Templates, but it is not available when I type “setpref” in a code window. I’m guessing that I’ve missed something obvious but can’t work out what.
Any ideas??

How to&Answers:

To make the Live Templates appear again, do the following:

1) Open Editor>Live Templates

2) When you find templates with issues, select them and do step 4-6

3) At the bottom, click Change where it says “Applicable in…”

4) In the popup, under Java select statement to make templates like logd, logm, logw etc be available inside methods.

5) Select declaration to make templates like logt available in classes’ field declarations.

Done!

Visit this link – https://www.reddit.com/r/androiddev/comments/3n9nis/issues_with_live_templates_in_android_studio_try/?st=j0pjkc4w&sh=e84eb254

Have fun ! 🙂 It works.

Answer:

Please make sure that you’ve correctly specified the context for your live template (the set of languages in which it’s available).