问题
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