Green Dao Could not init DAOConfig
Asked Answered
M

2

3

I tried to use an old android application, that's use Green Dao such us database also this applicatioh had a flavour, so I compile and I install the apk but the app wan't start it gives this exception :

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)

the rest of causes :

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) 

this my gradle :

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') }
Marga answered 15/12, 2015 at 10:39 Comment(8)
Did u found the root cause of the issue? got solution? post it if so.Quade
Sorry my friend, I passed to Realm it's a perfect database than GreenDao,I advice you to use it ! Have a nice day.Marga
Can u provide a link for trying out realm? like a snippet for CRUD operationsQuade
try this link www.realm.ioMarga
Friend, are u using MAC or windows? i need realm browser for windows, unfortunately for windows realm not supporting browser, if u are using windows then tell me how to handle the browsing part?Quade
Sorry my friend, I use Mac.Marga
Fine friend, i got the solution though Stetho-realm for Android, its supporting realm browser from chrome browser inspection.Quade
nice, if you want any information text me at : [email protected]Marga
I
1

I add the proguard-rules below.

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

(xxx is the packageName where I put the DAO class file.)

It works for me.

Ilmenite answered 12/4, 2019 at 9:30 Comment(1)
Thank you! for me it doesn't need .dao.Sides
I
0

------ property declare like this ------

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;
}

if you don't write public so occur error like Caused by: de.greenrobot.dao.DaoException: Could not init DAOConfig or static than Caused by: java.lang.NullPointerException: Attempt to read from field 'int de.greenrobot.dao.Property.ordinal' on a null object reference

Imbed answered 23/4, 2018 at 10:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.