当我尝试在AsyncTask内部或外部实例化一个新的DaoGenerator时,它会崩溃我的应用程序。
对DaoGenerator进行实例化:
Schema schema = new Schema(1,"com.example.administrator.teste");
Entity user = schema.addEntity("User");
user.addIdProperty();
user.addStringProperty("name");
user.addStringProperty("user");
user.addStringProperty("pass");
try {
new DaoGenerator().generateAll(schema, "../db/src");
}catch (Exception e)
{
e.printStackTrace();
}
它给出了以下例外:
引起:java.lang.VerifyError: freemarker的/转/豆/ ClassIntrospector 在freemarker.ext.beans.BeansWrapper。(BeansWrapper.java:318) 在freemarker.ext.beans.BeansWrapper。(BeansWrapper.java:245) 在freemarker.ext.beans.BeansWrapper。(BeansWrapper.java:196) 在freemarker.ext.beans.BeansWrapperSingletonHolder。(BeansWrapperSingletonHolder.java:27) 在freemarker.ext.beans.BeansWrapper.getDefaultInstance(BeansWrapper.java:795) at freemarker.template.ObjectWrapper。(ObjectWrapper.java:49) at freemarker.template.Configuration.getDefaultObjectWrapper(Configuration.java:1552) 在freemarker.core.Configurable。(Configurable.java:151) 在freemarker.template.Configuration。(Configuration.java:357) 在freemarker.template.Configuration。(Configuration.java:233) 在de.greenrobot.daogenerator.DaoGenerator。(DaoGenerator.java:61) at com.example.administrator.teste.LoginActivity $ CreateDatase.doInBackground(LoginActivity.java:62) at com.example.administrator.teste.LoginActivity $ CreateDatase.doInBackground(LoginActivity.java:48) 在android.os.AsyncTask $ 2.call(AsyncTask.java:288) 在java.util.concurrent.FutureTask.run(FutureTask.java:237) 在android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587) 在java.lang.Thread.run(Thread.java:841)
我试图通过在项目freemarker中编译来解决这个问题,但它给出了同样的例外。
其他信息:
Grandle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.administrator.teste"
minSdkVersion 19
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'de.greenrobot:greendao-generator:1.3.1'
compile 'freemarker:freemarker:2.3.9'
compile 'org.freemarker:freemarker:2.3.21'
}
答案 0 :(得分:2)
引自http://freemarker.org/freemarkerdownload.html:
Until about 2007 the Maven group name was "freemarker" instead of "org.freemarker",
and as the XML comment above says, this can cause problems,
as Maven will see them as two independent artifacts with no version conflict.
If you run into this issue, find the dependency that depends on the old FreeMarker,
and add this to your application's POM where you declare the problematic dependency:
<dependency>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<exclusions>
<exclusion>
<groupId>freemarker<!-- Do NOT use this org-less group! --></groupId>
<artifactId>freemarker</artifactId>
</exclusion>
</exclusions>
</dependency>
在依赖项中尝试此操作:
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.21</version>
</dependency>
<dependency>
<groupId>de.greenrobot</groupId>
<artifactId>greendao-generator</artifactId>
<version>1.3.1</version>
<exclusions>
<exclusion>
<groupId>freemarker</groupId>
<artifactId>freemarker</artifactId>
</exclusion>
</exclusions>
</dependency>
或者使用Gradle:
compile 'org.freemarker:freemarker:2.3.21'
compile('de.greenrobot:greendao-generator:1.3.1') {
exclude module: 'freemarker'
}