使用ObjectBox Box对象

时间:2018-04-05 17:41:55

标签: objectbox

当我通过登录活动登录并导航到MainActivity时,我的应用程序崩溃了。 MainActivity在OnCreate方法上有一个ObjectBox Box对象引用。

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //ObjectBox Box object reference for the BookEntity class 
    BoxStore boxStore = ((App) getApplication()).getBoxStore();
    bookBox = boxStore.boxFor(BookEntitiy.class);

    //bind views using butterknife
    ButterKnife.bind(this);

    //reference the BookViewModel ViewModel
    viewModel = ViewModelProviders.of(this).get(BookViewModel.class);

    //call method
    observeViewModel();
}

当我删除或评论Box对象参考代码时,应用程序会正确导航到MainActivity.java活动而不会崩溃。

导致这种情况的原因是什么?

堆栈跟踪:

04/05 14:23:47:启动应用程序 $ adb shell am start -n" com.example.novo0007.gfbtestarcht / com.example.novo0007.gfbtestarcht.Home.LoginActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER 已连接到设备上的进程30637 huawei-huawei_vns_l23-GVYHP17607000187 从应用程序捕获和显示logcat消息。可以在" Logcat输出中禁用此行为" "调试器"的一部分设置页面。 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_dependencies_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_dependencies_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_0_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_0_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_1_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_1_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_2_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_2_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_3_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_3_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_4_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_4_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_5_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_5_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_6_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_6_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_7_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_7_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_8_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_8_apk.apk @ classes.dex)因为非0退出状态 W / art:失败的execv(/ system / bin / dex2oat --runtime-arg -classpath --runtime-arg --debuggable --instruction-set = arm64 --instruction-set-features = smp,a53 --runtime- arg -Xrelocate --boot-image = / system / framework / boot.art --runtime-arg -Xms64m --runtime-arg -Xmx512m --instruction-set-variant = generic --instruction-set-features = default - -dex-file = / data / app / com.example.novo0007.gfbtestarcht-2 / split_lib_slice_9_apk.apk --oat-file = / data / dalvik-cache / arm64 / data @ app @ com.example.novo0007.gfbtestarcht- 2 @ split_lib_slice_9_apk.apk @ classes.dex)因为非0退出状态 I / InstantRun:启动即时运行服务器:是主进程 I / HwCust:为类android.app.HwCustHwWallpaperManagerImpl找到构造函数 W / art:在Android 4.1之前,方法android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter,android.content.res.ColorStateList,android.graphics.PorterDuff $ Mode)会有错误地覆盖了android.graphics.drawable.Drawable中的package-private方法 I / HwSecImmHelper:mSecurityInputMethodService为null I / OpenGLRenderer:初始化的EGL,版本1.4 W / art:在Android 4.1之前,方法int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int,boolean)会错误地覆盖android.widget.ListView中的package-private方法 I / HwSecImmHelper:mSecurityInputMethodService为null I / HwSecImmHelper:mSecurityInputMethodService为null I / System:core_booster,getBoosterConfig = false I /处理:发送信号。 PID:30637 SIG:9 申请已终止。

1 个答案:

答案 0 :(得分:0)

我完成了这个问题。网站上的ObjectBox的数据库设置和配置不是很清楚,一步一步。我必须在Udemy上阅读Objectbox的视频教程才能正确设置。请创建关于正确设置ObjectBox的清晰教程/文档,尤其是使用gradle文件和manifest.xml等。谢谢。

相关问题