NoClassDefFoundError when trying to run DaoGenerator for GreenDAO
Set the build.gradle
file for your generator like this (especially note the mainClassName
):
Then click the "Gradle" tab in the right sidebar of Android Studio and select the "run" task of your daogenerator like this:
It's worked for me , more details check link : https://github.com/greenrobot/greenDAO/issues/619http://greenrobot.org/greendao/documentation/generator/#Triggering_generation
Apart from what @Jesto Paul mentioned, I changed the following in the Generator class
new DaoGenerator().generateAll(schema, "./app/src/main/java"); - shows Path not exist.
to
new DaoGenerator().generateAll(schema, "../app/src/main/java");
(added double dot for the path). After doing this the generator create the tables to the folder.
For some reason, I ran into the same problem after updating android buildToolsVersion.
After some time of searching, i've accidentally checked "Run > Edit Configurations..." for the DaoGenerator-Application.
In the list of JRE "Android API 25 Platform" was selected. So I changed it back to the external Java running on my computer (e.g. "1.8", did it before some days ago). That solved it for me.
Edit: in this project I use GreenDAO 2.1.0
Edit 2:
https://github.com/greenrobot/greenDAO/issues/619 - http://greenrobot.org/greendao/documentation/generator/#Triggering_generation