LiteOrm報NullPointException的問題

公司android項目用到了數據庫,但是執行後報nullpointexception錯誤

private static LiteOrmInstance sInstance;

private static final String DB_NAME = "uploaded.db";

private LiteOrm mLiteOrm;
private DataBaseConfig mConfig;

private LiteOrmInstance() {

        mLiteOrm = LiteOrm.newSingleInstance(HLFConnect.getContext(),DB_NAME);
        mLiteOrm.setDebugged(true);
    
}

public static LiteOrmInstance getInstance(){
    if (sInstance == null) {
        synchronized (LiteOrmInstance.class){
            if (sInstance == null){
                sInstance = new LiteOrmInstance();
            }
        }
    }
    return sInstance;
}
如上紅色的那句報空指針 找到我的HLFConnect 的Application類

private static LiteOrmInstance sInstance;

private static final String DB_NAME = "uploaded.db";

private LiteOrm mLiteOrm;
private DataBaseConfig mConfig;

private LiteOrmInstance() {

        mLiteOrm = LiteOrm.newSingleInstance(HLFConnect.getContext(),DB_NAME);
        mLiteOrm.setDebugged(true);
    
}

public static LiteOrmInstance getInstance(){
    if (sInstance == null) {
        synchronized (LiteOrmInstance.class){
            if (sInstance == null){
                sInstance = new LiteOrmInstance();
            }
        }
    }
    return sInstance;
}
發現並沒有問題,之後我用Android studio的lint工具 詳情請參考另外一個blog http://blog.csdn.net/qq_16131393/article/details/51172488 上面有lint的使用方法

在Android > Lint > Correctness裏 發現 原來是The '<appliction>com.****.app.HLFConnect' is not registered in the manifest

so

<application
    android:allowBackup="true"
    android:name=".app.HLFConnect"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"

    >

加上亮藍色那句就好了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章