使用OrmLite时NoClassDefFoundError

时间:2017-11-10 18:47:25

标签: java android noclassdeffounderror ormlite

以下是我的<COMMENT>\n班级定义:

DBConfig.java

我的public class DBConfig extends OrmLiteConfigUtil { private static final Logger logger = Logger.getLogger(DBConfig2.class.getName()); private static final String CONFIG_FILE_NAME = "ormlite_config.txt"; private static final Class<?>[] CLASSES = new Class[]{ User.class }; public static void main(String[] args) throws IOException, SQLException, ClassNotFoundException { File rawFolder = new File("res/raw"); if (!rawFolder.exists()) { boolean rawCreated = rawFolder.mkdirs(); if (!rawCreated) { logger.warning("could not create raw folder"); System.exit(1); } else { logger.info("created raw folder"); } } writeConfigFile(CONFIG_FILE_NAME, CLASSES); } } 课程:

User.java

当我使用下面捕获的运行配置运行DBConfig时,收到错误消息 @DatabaseTable(tableName = "users") public class User { private static final String ID = "user_id"; private static final String USER_NAME = "name"; private static final String USER_AGE = "age"; private static final String USER_DOB = "dob"; @DatabaseField(columnName = ID, id = true) private long id; @DatabaseField(columnName = USER_NAME) private String name; @DatabaseField(columnName = USER_AGE) private int age; @DatabaseField(columnName = USER_DOB) private String dob; // getters and setters... }

enter image description here

但是我已经在模块的build.gradle文件中正确添加了所需的依赖项: Error: Could not find or load main class com.alex.bestapp.DBConfig Caused by: java.lang.NoClassDefFoundError: com/j256/ormlite/android/apptools/OrmLiteConfigUtil

非常感谢任何有关如何解决此问题的帮助。

0 个答案:

没有答案