1

I'm handling an Android Project my company started last year. I got a GreenDaoGenerator project with the infamous custom ExampleDaoGenerator.java. I'm pretty sure this is all well configured in order to work well and generate my entities.

I started developing the Android Project (which is in another folder/package, of course) but now I need to change the way Entities are instantiated in it.

I have a good amount of classes with the

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit. 

on the top of them and I'd like to re-generate them since I commented out some rows in my custom ExampleDaoGenerator.

How can I do that? GreenDaoGenerator is not an Android Studio project, doesn't have any build.gradle file. It doesn't have any .class file either, just the java file and libraries to load for DaoGeneration. I didn't find anywhere in GreenDao documentation how to run the proper generation and harvest the created classes.

I tried of course javac the.full.path/src/whatever/ExampleDaoGenerator.java but it didn't work :-(

Do you happen to see what I'm doing wrong? I expected Android Studio Project to re-generate the database whenever the signatures are changed but it seems like it does not.

Thank you

Marco Zanetti
  • 4,051
  • 6
  • 32
  • 48

2 Answers2

4

You need to add a Java library module (File > New > New module..) to your Android project (assuming you're using Android Studio), and insert the generation code inside public static void main(String[] args) {} in this module's .java class. Then Run it and the code will be generated in you main app's module.

See how I did it in my blog post.

lomza
  • 9,412
  • 15
  • 70
  • 85
0

mmm.... manually? backup previous created classes (model), run the generator again and compare-update data?

I don't know if there are any new doc here, but allways is a good reading place. get project also available.

Good luck!

Gabriel Gómez
  • 311
  • 2
  • 10