Android下ObjectBox使用ObjectBrowser报错duplicate class问题


Android的orm开源库也挺多的,但是个人项目使用的时候总有一些不满意的地方,稳定的库太复杂了,为了一丁点存储功能引入一个大的库显然不合适,小巧的要么bug多又不太稳定要么使用起来麻烦,在一些项目里面使用了一段时间ObjectBox之后,我把它引入到了一些新的项目,前阵子我想通过objectbrowser查看数据的时候,发现无法编译通过, gradle配置如下

ext.objectboxVersion = '2.3.4'
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    releaseImplementation "io.objectbox:objectbox-kotlin:$objectboxVersion"
    kapt "io.objectbox:objectbox-processor:$objectboxVersion"

    debugImplementation "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
}

结果运行的时候一直报错

Duplicate class io.objectbox.android.AndroidObjectBrowser found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.AndroidObjectBrowserReceiver found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.AndroidObjectBrowserService found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.AndroidScheduler found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.AndroidScheduler$Runner found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.BuildConfig found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.ObjectBoxDataSource found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.ObjectBoxDataSource$1 found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.ObjectBoxDataSource$Factory found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.ObjectBoxLiveData found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)
Duplicate class io.objectbox.android.ObjectBoxLiveData$1 found in modules classes.jar (io.objectbox:objectbox-android-objectbrowser:2.3.4) and classes.jar (io.objectbox:objectbox-android:2.3.4)

Go to the documentation to learn how to Fix dependency resolution errors.

错误提示是有类重复引入,我就纳闷了,都没有引入多个,这问题是从哪冒出来的,不管是清理缓存还是各种exclude都不管用,鉴于之前这篇文章ANDROID工程出现FAILED TO RESOLVE: SUPPORT-FRAGMENT出现的问题,我又脑洞大开,各种操作尝试,最后把

//bottom of build.gradle
apply plugin: 'io.objectbox'

放到app模块gradle文件的最后一行就解决了,这样在adb forward tcp:8090 tcp:8090之后,就可以通过http://localhost:8090/index.html访问数据库了。


内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://11000011.com/?id=120

« 上一篇 下一篇 »

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

主机推荐

  • 搬瓦工