objectbox / objectbox/objectbox-java

Support Gradle build cache

未关闭
#1,114 5 条评论 5 个 reaction 已指派 1 人 在 GitHub 查看

@greenrobot-team 已经在做这个了。

开始于 2023年7月10日。

bug
主要语言
Java
星标
4.6k
派生
311
PR 合并指标
30 天内没有已合并 PR

描述

The bug is occurred in an Android Project.

Description of the bug
During a manual conflict resolution, the objectbox-models/default.json file may accidentally contain duplicated indexId entries. During the build time, we don't have any errors. The project builds successfully, and the build output is cached to the Gradle Build Cache. Only at runtime, when we build BoxStore instance, an error occurred: io.objectbox.exception.DbSchemaException: Duplicate index ID 2 found for property .... Moreover, when a developer fixes duplicated indexId entries in the objectbox-models/default.json file and rebuilds the project, the error is still in place due to the result of the previous build is used from the Gradle Build Cache. It incurs hard-to-debug problems for our dev team.

Basic info:

  • ObjectBox version: 3.5.1
  • Reproducibility: always
  • Device: any device
  • OS: reproduced on Android 11, 13

Steps to reproduce the behavior:

  1. Activate the Gradle Build Cache: add org.gradle.caching=true in the gradle.properties file.
  2. Add two ObjectBox entities (e.g. User and Company) with the unique name property.
  3. Build the project to generate a objectbox-models/default.json file.
  4. Make changes to the objectbox-models/default.json file: set the same value to both indexId entries (Company.name and User.name).
  5. Rebuild the project.
  6. Install APK and launch the app. There is the error: io.objectbox.exception.DbSchemaException: Duplicate index ID 2 found for property ...
  7. Fix duplicated indexId in the objectbox-models/default.json file.
  8. Rebuild the project.
  9. Install APK and launch the app. There is still the same error. The result of the previous build is used.

Expected behavior

  • The Duplicate index ID error should occur during the build time, not at runtime.
  • Any change to the objectbox-models/default.json file should lead to the invalidation of the Gradle Build Cache to prevent the usage of stale data from the previous build.

Code
I've prepared the demo project to reproduce the problem with the described above steps:
https://github.com/rAseri/ObjectBoxDemo

Logs, stack traces

Process: com.example.myapplication, PID: 24377
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapplication/com.example.myapplication.MainActivity}: io.objectbox.exception.DbSchemaException: Duplicate index ID 2 found for property User.name
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loop(Looper.java:223)
	at android.app.ActivityThread.main(ActivityThread.java:7656)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。