找不到ormlite配置文件

时间:2017-02-08 12:53:41

标签: android ormlite

我正在尝试在我的Android Studio项目上安装ORMlite,但我无法获取R.raw.ormlite_config文件,我发现:https://github.com/stephanenicolas/ormlite-android-gradle-plugin但仍然无法正常工作......

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        classpath 'com.github.stephanenicolas.ormgap:ormgap-plugin:1.0.12'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}


apply plugin: 'com.android.application'
apply plugin: 'ormgap'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "..."
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 12
        versionName "1.2.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        repositories {
            maven { url 'https://oss.sonatype.org/content/repositories/ksoap2-android-releases/' }
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:recyclerview-v7:23.0.0'
    compile 'com.google.android.gms:play-services:7.5.0'
    compile 'com.j256.ormlite:ormlite-android:5.0'
    compile files('libs/ksoap2-android-assembly-3.6.1-jar-with-dependencies.jar')
}

对于我的DataHelper:

public class DatabaseHelper extends OrmLiteSqliteOpenHelper {


    private static final int DATABASE_VERSION = 4;
    private static final String DATABASE_NAME = "solutis.db";


    private Dao<Demandes, Integer> simpleDao = null;
    private RuntimeExceptionDao<Demandes, Integer> simpleRuntimeDao = null;

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION, android.R.raw.ormlite_config);
    }


    @Override
    public void onCreate(SQLiteDatabase db, ConnectionSource connectionSource){

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, ConnectionSource connectionSource, int oldVersion, int newVersion) {

    }

}

2 个答案:

答案 0 :(得分:0)

为什么需要这个文件?你可以把它添加到
gradle这个.. mycustomdomainB.com --> myapp.firebaseapp.com/routeB mycustomdomainC.com --> myapp.firebaseapp.com/routeC mycustomdomainD.com --> myapp.firebaseapp.com/routeD mycustomdomainE.com --> myapp.firebaseapp.com/routeE 并开始使用db。

compile 'com.j256.ormlite:ormlite-core:4.48'
    compile 'com.j256.ormlite:ormlite-android:4.48'

答案 1 :(得分:0)

  

然后,您需要使用ORMLite配置创建数据库   在构建期间生成的文件(注意:您首先需要   升级系统,获取生成的文件,然后引用它。)

请参阅文档链接:http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_4.html#Config-Optimization

  

ORMLite支持从文本加载数据配置   配置文件。创建DAO时,这些配置将会   使用,完全不需要任何注释方法调用。

     
      
  1. OrmLiteConfigUtil实用程序类在原始资源文件夹中写入ormlite_config.txt配置文件   res/raw/ormlite_config.txt。您需要将此类扩展为   您自己的项目与DatabaseHelper类一起。应该看   类似的东西:
  2.   
public class DatabaseConfigUtil extends OrmLiteConfigUtil {
  public static void main(String[] args) throws Exception {
    writeConfigFile("ormlite_config.txt");
  }
}