objectbox-java: [1.1.0]io.objectbox.exception.DbException-->Could not create directory: /data/user/0/com.taoche.qctt/files/objectbox/objectbox

java.lang.RuntimeException:Unable to create application com.taoche.qctt.app.App: io.objectbox.exception.DbException: Could not create directory: /data/data/com.taoche.qctt/files/objectbox/objectbox
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4886)
......
Caused by:
io.objectbox.exception.DbException:Could not create directory: /data/data/com.taoche.qctt/files/objectbox/objectbox
io.objectbox.BoxStore.<init>(BoxStore.java:178)
io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:243)
com.taoche.qctt.app.App.onCreate(App.java:64)
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4862)
android.app.ActivityThread.access$1700(ActivityThread.java:169)
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1528)
android.os.Handler.dispatchMessage(Handler.java:102)
android.os.Looper.loop(Looper.java:159)
android.app.ActivityThread.main(ActivityThread.java:5671)
java.lang.reflect.Method.invoke(Native Method)
java.lang.reflect.Method.invoke(Method.java:372)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:964)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)

image image

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

@greenrobot We’ve released a new version with ObjectBox 1.2.0 and this bug report was not received again ,and the same as issure #230

I put the code into main process like tihs

 @Override
    public void onCreate() {
        super.onCreate();
        if (isMainProcess()) {
            //多通道推送
            MultiPushAgent.init(context);
            //友盟统计
            UmengAgent.init(this);
            //Bugly配置
            initCrashReport();
            //检测内存泄漏
            LeakCanary.install(this);
            //已读新闻
            boxStore = MyObjectBox.builder().androidContext(this).build();
            putNewsReadSet();
        }
    }


 private boolean isMainProcess() {
        ActivityManager am = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
        List<ActivityManager.RunningAppProcessInfo> processInfos = am.getRunningAppProcesses();
        String mainProcessName = getPackageName();
        int myPid = android.os.Process.myPid();
        for (ActivityManager.RunningAppProcessInfo info : processInfos) {
            if (info.pid == myPid && mainProcessName.equals(info.processName)) {
                return true;
            }
        }
        return false;
    }

I think this is the key to solving the problem,because @liujinchaoDS met the same bug when use the 1.2.1 version