项目继承ObjectBox在浏览器中查看数据库遇到的坑

来源:互联网 发布:继续教育网络培训总结 编辑:程序博客网 时间:2024/06/14 01:50

按照官网给出的配置步骤

在项目中的build.gradle中添加

buildscript{
    ext.objectboxVersion='1.3.3'
    repositories{
        jcenter()
        maven{url"http://objectbox.net/beta-repo/"}
    }
    dependencies{
        classpath'com.android.tools.build:gradle:2.3.3'
        classpath"io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
    }
}
 
然后再app下的build.gradle中添加

applyplugin:'com.android.application'
applyplugin:'io.objectbox'



3
4
5
6
7
8
9
10
11
dependencies{
    // all below should be added automatically by the plugin
 
    compile"io.objectbox:objectbox-android:$objectboxVersion"
    // some useful Kotlin extension functions
    // compile "io.objectbox:objectbox-kotlin:$objectboxVersion"
 
    annotationProcessor"io.objectbox:objectbox-processor:$objectboxVersion"
    // When using Kotlin use kapt instead:
    // kapt "io.objectbox:objectbox-processor:$objectboxVersion"
}
即可完美使用objectbox

但如果你想在调试的时候在浏览器中查看数据库,按照官网的步骤

在原来依赖的基础上直接加入




dependencies{
    debugCompile"io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
    releaseCompile"io.objectbox:objectbox-android:$objectboxVersion"
}
编译的时候就会报 jar包 冲突的错误

我们可以这样解决



项目下面的gradle文件
buildscript{
    ext.objectboxVersion='1.3.3'
    repositories{
        jcenter()
        maven{url"http://objectbox.net/beta-repo/"}
    }
    dependencies{
       // classpath'com.android.tools.build:gradle:2.3.3' (注释掉)
        classpath"io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
    }
}

app下的gradle文件

//applyplugin:'io.objectbox'(注释掉)

dependencies{
    // all below should be added automatically by the plugin
 
   // compile"io.objectbox:objectbox-android:$objectboxVersion"(注释掉)
    // some useful Kotlin extension functions
    // compile "io.objectbox:objectbox-kotlin:$objectboxVersion"
 
    //annotationProcessor"io.objectbox:objectbox-processor:$objectboxVersion"(注释掉)
    // When using Kotlin use kapt instead:
    // kapt "io.objectbox:objectbox-processor:$objectboxVersion"
debugCompile"io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
    releaseCompile"io.objectbox:objectbox-android:$objectboxVersion"
}
然后在你的Application中配置以下内容 即可


if(BuildConfig.DEBUG){
    newAndroidObjectBrowser(boxStore).start(this);
}


原创粉丝点击