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

按照官网给出的配置步骤

在项目中的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中添加

apply plugin : 'com.android.application'
apply plugin : '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文件

//apply plugin : '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 ) {
     new AndroidObjectBrowser ( boxStore ) . start ( this ) ;
}


猜你喜欢

转载自blog.csdn.net/yangzongbin/article/details/78730476