How to Generate Code GreenDAO with Android Studio

In this tutorial we will show you step by step how we have created sample application that presents our own Android Studio-GreenDao communication module. We tried to focus mainly on the implementation of database in freshly created Android Studio project and took other factors (such as layouts, modularity etc.) with a grain of salt. For those who haven't checked our Git yet - you can find our GreenDao module here.
So let's get started!

Step 1 - create new Android Project

For those who are not familiar with Android Studio IDE we recommend to go through Google tutorial - Getting Started With Android Studio.
  1. To create new project please select File -> New Project. The New Project wizards pop up. Fill up fields according to your liking or do it the way we did:
    createProject

    1. Press next. Check "Blank Activity" and next button again.
    2. Name your first activity BoxListActivity and the layout activity_box_list.
    3. Press finish.
And it's done. We have our project created. Now we can go to next step which is...

Step 2 - add GreenDao Generator module to project tree

We assume you have already downloaded our module. If not please go to our Git and do it now. Add MyDaoGenerator module to your project tree as additional package.
moduleAdded
As you can see MyDaoGenerator is recognized as Directory and not as Module like DaoExample. To change it we have to edit settings.gradle so it contains both ':DaoExample' and ':MyDaoGenerator' :
include ':DaoExample', ':MyDaoGenerator'  
After doing it, please click "Sync Project with Gradle Files" button. Your directory should look like a module now in project tree.

Step 3 - connect GreenDao Generator to DaoExample (main module)

So, MyDaoGenerator is currently recognized as a module. Now we have to configure it, so we can get database files from it. The only necessary thing to be changed is outputDir parameter in build.gradle file of MyDaoGenerator module.








First