{"record":{"id":"b9b69861b740996d","repo":"greenrobot/greenDAO","slug":"could-not-init-daoconfig","errorCode":null,"errorMessage":"Could not init DAOConfig","messagePattern":"Could not init DAOConfig","errorType":"exception","errorClass":"DaoException","httpStatus":null,"severity":"error","filePath":"DaoCore/src/main/java/org/greenrobot/greendao/internal/DaoConfig.java","lineNumber":94,"sourceCode":"            String[] nonPkColumnsArray = new String[nonPkColumnList.size()];\n            nonPkColumns = nonPkColumnList.toArray(nonPkColumnsArray);\n            String[] pkColumnsArray = new String[pkColumnList.size()];\n            pkColumns = pkColumnList.toArray(pkColumnsArray);\n\n            pkProperty = pkColumns.length == 1 ? lastPkProperty : null;\n            statements = new TableStatements(db, tablename, allColumns, pkColumns);\n\n            if (pkProperty != null) {\n                Class<?> type = pkProperty.type;\n                keyIsNumeric = type.equals(long.class) || type.equals(Long.class) || type.equals(int.class)\n                        || type.equals(Integer.class) || type.equals(short.class) || type.equals(Short.class)\n                        || type.equals(byte.class) || type.equals(Byte.class);\n            } else {\n                keyIsNumeric = false;\n            }\n\n        } catch (Exception e) {\n            throw new DaoException(\"Could not init DAOConfig\", e);\n        }\n    }\n\n    private static Property[] reflectProperties(Class<? extends AbstractDao<?, ?>> daoClass)\n            throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException {\n        Class<?> propertiesClass = Class.forName(daoClass.getName() + \"$Properties\");\n        Field[] fields = propertiesClass.getDeclaredFields();\n\n        ArrayList<Property> propertyList = new ArrayList<Property>();\n        final int modifierMask = Modifier.STATIC | Modifier.PUBLIC;\n        for (Field field : fields) {\n            // There might be other fields introduced by some tools, just ignore them (see issue #28)\n            if ((field.getModifiers() & modifierMask) == modifierMask) {\n                Object fieldValue = field.get(null);\n                if (fieldValue instanceof Property) {\n                    propertyList.add((Property) fieldValue);\n                }\n            }","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/greenrobot/greenDAO/blob/0bbb338e17c4cf28aba5aae62d42f73f50186157/DaoCore/src/main/java/org/greenrobot/greendao/internal/DaoConfig.java#L76-L112","documentation":"DaoConfig's constructor initializes keyIsNumeric and other metadata by reflecting over the entity and its Property fields; any Exception during this reflection (missing inner Properties class, illegal access, bad property types) is wrapped as DaoException \"Could not init DAOConfig\" with the cause attached. It happens when a DAO class is registered that greendao cannot reflect upon.","triggerScenarios":"Registering a DAO whose generated $Properties class is missing or out of sync with the entity (stale/failed annotation-processor run), a Property referencing a field type reflection can't resolve, or code changes to an entity without regenerating DAO classes.","commonSituations":"Editing an entity class after code generation (greenDAO generator/Gradle plugin) without regenerating; renaming entities so Foo$Properties no longer exists; ProGuard removing generated Property fields in release builds.","solutions":["Regenerate DAO classes: re-run the greendao Gradle plugin build / annotation processor so <Entity>$Properties matches the entity.","Inspect getCause() to see the underlying reflection error and fix the specific entity/property.","Clean and rebuild the project to remove stale generated sources.","Add ProGuard keep rules for generated classes: -keep class *$Properties { *; } and keep entity fields used by greendao."],"exampleFix":"// after editing an entity, before: relying on stale generated code\n// terminal:\n./gradlew clean :app:generateGreenDaoSources :app:build\n// build.gradle keep rule added:\n-keepclassmembers class * extends org.greenrobot.greendao.Property { *; }","handlingStrategy":"try-catch","validationCode":"try {\n    Class.forName(entityClass.getName() + \"$Properties\");\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"DAO classes not generated for \" + entityClass + \"; run greendao generator\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    daoSession = new DaoMaster(db).newSession();\n} catch (DaoException e) {\n    Throwable cause = e.getCause(); // reflection error naming the bad entity\n    log.severe(\"DAOConfig init failed: \" + cause + \" — regenerate DAO classes\");\n}","preventionTips":["Always regenerate DAO classes after editing entities (greenDAO generator/Gradle plugin)","Clean rebuild when entity and generated $Properties may be out of sync","Add ProGuard keep rules for *$Properties and entity fields","Inspect DaoException.getCause() to identify the offending entity"],"tags":["database","reflection","code-generation","greendao"],"backgroundTag":"class-not-found","analyzedSha":"0bbb338e17c4cf28aba5aae62d42f73f50186157","analyzedAt":"2026-09-08T03:22:36.050Z","contentChangedAt":"2026-09-08T03:22:36.050Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}