Green Dao无法启动DAOConfig

问题描述 投票:3回答:2

我试图使用一个旧的Android应用程序,这是使用Green Dao这样的我们数据库也这个应用程序有味道,所以我编译,我安装apk但应用程序不开始它给出了这个例外:

Process: com.xxxx.boeufaujardin, PID: 20011 java.lang.RuntimeException: Unable to create application com.android.tools.fd.runtime.BootstrapApplication: de.greenrobot.dao.DaoException: Could not init DAOConfig
                                                   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4556)
                                                   at android.app.ActivityThread.access$1500(ActivityThread.java:151)
                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                   at android.os.Looper.loop(Looper.java:135)
                                                   at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                   at java.lang.reflect.Method.invoke(Method.java:372)
                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                Caused by: de.greenrobot.dao.DaoException: Could not init DAOConfig
                                                   at de.greenrobot.dao.DaoConfig.<init>(DaoConfig.java:88)

其余原因:

Caused by: java.lang.NullPointerException: Attempt to read from field 'int de.greenrobot.dao.Property.ordinal' on a null object reference
                                                       at de.greenrobot.dao.DaoConfig.reflectProperties(DaoConfig.java:99)
                                                       at de.greenrobot.dao.DaoConfig.<init>(DaoConfig.java:51)
                                                       at de.greenrobot.dao.AbstractDaoMaster.registerDaoClass(AbstractDaoMaster.java:43) 

这是我的傻瓜:

apply plugin: 'com.android.application'

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://download.crashlytics.com/maven' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
    } } apply plugin: 'android' apply plugin: 'crashlytics' repositories {
    mavenCentral()
    maven { url 'http://download.crashlytics.com/maven' } }


android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'

    //useOldManifestMerger false

    dexOptions {
        preDexLibraries = false
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }

    signingConfigs {
        debug_config {

        }
        release_config {

        }
    }
    compileSdkVersion 19
    buildToolsVersion '19.1.0'
    defaultConfig {
        applicationId 'com.xxxxx.xx'
        minSdkVersion 11
        targetSdkVersion 19
        versionCode 11
        versionName '0.3'
        signingConfig signingConfigs.debug_config
        // Enabling multidex support.
      //  multiDexEnabled true
    }
    buildTypes {
        release {
            debuggable false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {

            debuggable true
            signingConfig signingConfigs.debug_config
            //renderscriptDebugBuild false
        }
    }
    productFlavors {
        Menu {
            applicationId "com.paperpad.menu"
            manifestPlaceholders = [activityLabel : "Menu", gcmPackage : "com.paperpad.menu"]
            minSdkVersion 11
            signingConfig signingConfigs.debug_config
            targetSdkVersion 19
            versionCode 11
            versionName '0.3'

            ext.enableCrashlytics = false
        }
        ServiceApps {
            ext.enableCrashlytics = false // true
            applicationId "xxxx.xxxxx.boeufaujardin"
            minSdkVersion 11
            signingConfig signingConfigs.debug_config
            targetSdkVersion 19
            versionCode 19
            versionName '0.5.4'

        }
    }

    sourceSets { //        main { //            manifest.srcFile 'AndroidManifest.xml' //            java.srcDirs = ['java'] //         resources.srcDirs = ['res'] //            aidl.srcDirs = ['src'] //    renderscript.srcDirs = ['src'] //            res.srcDirs = ['res'] //  assets.srcDirs = ['assets'] //        }


        ServiceApps {
            manifest.srcFile 'ServiceApps/AndroidManifest.xml'
            resources.srcDirs = ['ServiceApps/res']
            res.srcDirs = ['ServiceApps/res']
        }
    } }

dependencies {
    compile('com.android.support:appcompat-v7:19.1.0') {
        // really use 19.1.0 even if something else resolves higher
        //force = true
       exclude module: 'support-v4'}

   // compile 'com.android.support:multidex:1.0.1'
    //compile 'com.crashlytics.android:crashlytics:1.+'
    compile project(':headerListView')
    compile files('libs/freemarker.jar')
    compile files('libs/httpmime-4.1.jar')
    compile files('libs/crashlytics.jar')
    compile files('libs/simple-xml-2.6.9.jar')
    compile files('libs/json-simple-1.1.1.jar')
    compile files('libs/greenDAO.jar')
    compile files('libs/gcm-src.jar')
    compile files('libs/gcm.jar')
    compile files('libs/greenDAO-generator.jar')
    compile files('libs/disklrucache-1.3.1.jar')
    compile files('libs/httpclient-4.2.3.jar')
    compile files('libs/trace.jar')
    compile files('libs/jackson-databind-2.1.4.jar')
    compile files('libs/jackson-core-2.1.4.jar')
    compile files('libs/jackson-annotations-2.1.4.jar')
    compile files('libs/universal-image-loader-1.8.4.jar')
    compile files('libs/universal-image-loader-1.8.4-sources.jar')
    compile files('libs/picasso-2.2.0.jar')
    compile project(':library')
    compile files('libs/Android-BitmapCache-2.1.jar')
    //compile 'org.jraf:android-switch-backport:1.3.1'
    compile files('libs/android-support-v13.jar') }
java android greendao
2个回答
0
投票

------财产声明如下------

public class FolderDao extends AbstractDao<Folder, Long> {
public static final String TABLENAME = "FOLDER";
private DaoSession daoSession;

public static class Properties {
    public static final Property FolderPath = new Property(8, String.class, "folderPath", false, "FOLDER_PATH");
    public static final Property FolderSourceId = new Property(5, Long.class, "folderSourceId", false, "FOLDER_SOURCE_ID");
    public static final Property Id = new Property(0, Long.class, "id", true, "_id");
    public static final Property IsCamera = new Property(3, Boolean.class, "isCamera", false, "IS_CAMERA");
    public static final Property IsHidden = new Property(7, Boolean.class, "isHidden", false, "IS_HIDDEN");
    public static final Property IsUserCreated = new Property(6, Boolean.class, "isUserCreated", false, "IS_USER_CREATED");
    public static final Property Name = new Property(1, String.class, "name", false, "NAME");
    public static final Property Source = new Property(4, Integer.class, "source", false, "SOURCE");
    public static final Property UserType = new Property(2, String.class, "userType", false, "USER_TYPE");
}

public FolderDao(DaoConfig daoConfig) {
    super(daoConfig);
}

public FolderDao(DaoConfig daoConfig, DaoSession daoSession) {
    super(daoConfig, daoSession);
    this.daoSession = daoSession;
}

如果你不写公共所以发生错误如由引起:de.greenrobot.dao.DaoException:无法初始化DAOConfig或静态而不是由引起:java.lang.NullPointerException:尝试从字段'int de.greenrobot.dao读取.Property.ordinal'在空对象引用上


0
投票

我在下面添加了proguard规则。

-keep class xxx.dao.**{*;}

(xxx是我放置DAO类文件的packageName。)

这个对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.