Every time I create a new Fragment in my Android Studio for the project, it creates android.support.v4.app.Fragment, which is not what I want. Also, it alsways triggers a gradle update. How to set default Fragment to android.app.Fragment when creating new one with wizard and get rid of gradle updates?
For future readers!
As CommonsWare mentioned in comments changing the templates may not last longer as Android Studio updates may overwrite them. So you may create your own custom file templates as described in following article.
https://riggaroo.co.za/custom-file-templates-android-studio/
Here you may have to create two file templates
Another way to go about changing the fragment template is to backup the original files of that you are going modify and modify the existing templates and backup the modified templates in order to restore the modifications after an Android Studio update.
It's important to backup original files before modification, because when updating android studio in future, it will notify you about files being modified, so the update could not be completed. So you have to restore the original version of the modified files, before updating the android studio.
If you need to change Fragment template (Blank fragment template), navigates to
[android-studio-ndredirectory]/plugins/android/lib/templates/other/BlankFragment/root/src/app_package
and modify the source file of your choice. (BlankFragment.kt.ftl
or BlankFragment.java.ftl
), in order to modify the source file template.
Navigate to
[android-studio directory]/plugins/android/lib/templates/other/BlankFragment/root/res/layout
and modify the fragment_blank.xml.ftl
, in order to modify the layout file template.
After doing your modifications, you may backup the BlankFragment
directory, so you can restore your changes, after the Android Studio update.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With