Working Directory : null environment when running Process.Builder on android

蓝咒 提交于 2020-01-11 12:44:28

问题


I am using two phones, Galaxy Nexus(JellyBean) and Nexus 5(KitKat). I am trying to execute a script which exists in

/data/folder/scripts/run.sh

I use Process.Builder to build the command. This command is built by getting

Environment.getDataDirectory().toString() + "/folder/scripts/run.sh"

There are no issues running this on the Galaxy Nexus but when I run it on the Nexus 5, I catch an exception when I run the process.start(). The output which I get contains:

Error running exec(). Command: [/data/folder/scripts/run.sh, "param"]. Working directory: null Environment: [ADNROID_ROOT=/system ... ]

The directory structure of my scripts is the same on both files.

EDIT:

So I was looking at the logcat as soon as I load the application and I think I've pinpointed the issue.

There's an ERROR saying Manifest file not found. WARNING: java.io.FileNotFoundException /data/folder/Manifest: open failed EACCESS (Permission Denied).

This doesn't come up for the Galaxy Nexus which is running JellyBean. Is it some security issue with KitKat?


回答1:


The issue was due to not having root access. Fixed when SuperSu granted permission to the application.



来源:https://stackoverflow.com/questions/22815363/working-directory-null-environment-when-running-process-builder-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!