wkhatch wkhatch - 1 year ago 59
Android Question

greenDAO schema generation with relative output path; failing with i/o not found

Following along with this tutorial, I've been able to create a working app module that compiles and runs, but fails if I pass a relative path to the generateAll method. It works fine if I specify an absolute path. My android studio project is composed of a few modules, structured like

project_root, with sub directories for each of it's modules



Each has it's own src directories, and I'm calling the generateAll like:

new DaoGenerator().generateAll(schema,

which results in an io error, indicating that the directory doesn't exist. I've modified the path to many reasonable alternatives, and confirmed that the paths exist on disk, but still getting the error. The absolute path works fine, so I'm trying to understand what I'm missing to get it working with a relative path. Thanks.

Answer Source

The outDir parameter is expected to be relative to the project directory.

For example, suppose your MyDaoGenerator class is in module1 under projectA and you want to generate the DAO classes into a separate module2 of the same project ...

        src/main/java/      <-- target directory

... the outDir parameter would be module2/src/main/java.