错误代码:
错误描述,在三星、小米手机上运行没问题,在华为手机上抛出这个异常。
网上查询没有找到原因。
官网上提示说没有在application初始化的情况会抛出这个异常,但是初始化以后还是报这个错误。
查看源码:
/** * @param table The table to lookup the database for. * @return the corresponding {@link DatabaseDefinition} for the specified model */ public static DatabaseDefinition getDatabaseForTable(Class<?> table) { DatabaseDefinition databaseDefinition = globalDatabaseHolder.getDatabaseForTable(table); if (databaseDefinition == null) { throw new InvalidDBConfiguration("Model object: " + table.getName() + " is not registered with a Database. " + "Did you forget an annotation?"); } return databaseDefinition; }
/** * Helper method used to store a database for the specified table. * * @param table The model table * @param databaseDefinition The database definition */ public void putDatabaseForTable(Class<?> table, DatabaseDefinition databaseDefinition) { databaseDefinitionMap.put(table, databaseDefinition); databaseNameMap.put(databaseDefinition.getDatabaseName(), databaseDefinition); databaseClassLookupMap.put(databaseDefinition.getAssociatedDatabaseClassFile(), databaseDefinition); }
/** * This is generated code. Please do not modify */ public final class DatabaseareaNew_Database extends DatabaseDefinition { public DatabaseareaNew_Database(DatabaseHolder holder) { holder.putDatabaseForTable(Njzplace.class, this); models.add(Njzplace.class); modelTableNames.put("Njzplace", Njzplace.class); modelAdapters.put(Njzplace.class, new Njzplace_Table(holder, this)); }
追溯源码,并没有发现问题。
后来,突然想到
这里会不会是混淆的时候,导致的问题,因为我在debug模式中也是开启了混淆,后来发现果然是这个原因(大家可能在平时运行时没问题,但在正式签名的apk运行时会出现这个错误)。解决方法:
在 proguard-rules.pro 中添加dbflow的混淆规则
这里会不会是混淆的时候,导致的问题,因为我在debug模式中也是开启了混淆,后来发现果然是这个原因(大家可能在平时运行时没问题,但在正式签名的apk运行时会出现这个错误)。解决方法:
在 proguard-rules.pro 中添加dbflow的混淆规则
问题就此解决。