view raw
Fabian Fabian - 11 months ago 62
Android Question

greenDAO: ftl-templates not found

I'm using the greenDAO for Android and I want to edit the greenDAO generator, because it overwrites @SerializedName which I need for GSON every time I change something on my database.

So I was adding greenDAO from to my Android Studio project by File -> New -> Import Module... and just selected the GreenDaoGenerator-module.

Next, I build my java module to generate the greenDAO database, which uses the GreenDaoGenerator-module as dependency and I get an exception that the template dao.ftl was not found.

Can someone please help me? I'm new to Android and do not check, why it doesn't find the file.

Exception in thread "main" Template "dao.ftl" not found.
at freemarker.template.Configuration.getTemplate(
at freemarker.template.Configuration.getTemplate(
at de.greenrobot.daogenerator.DaoGenerator.<init>(
at com.example.GreenDaoCreater.main(

Here is a screenshot from the project structure. I hope it helps.

enter image description here


The problem is change in path of the template files. While I am not sure how to set the path to something relative, here is a hack that works. Open In the constructor, replace

config.setClassForTemplateLoading(this.getClass(), "/");


config.setDirectoryForTemplateLoading(new File("<your absolute path to templates>"));

You will need to find where the actual templates are stored. For me they were in /DaoGenerator/src-template/ directory.