在我的應用程序中,我試圖執行存在於我的SD卡上的本機代碼。如何使用Runtime.getRuntime()。exec(「cmd」)
File sdCard = getExternalFilesDir(null); // directory where native file is placed
String nativeFile = "nativeFile";
String cmd = "shell /system/bin/chmod 0777 " + sdCard.getAbsolutePath() + "/" + nativeFile;
Process proc = Runtime.getRuntime().exec(cmd);
但只要Runtime.getRuntime().exec(cmd)
被執行時,它拋出錯誤:
java.io.IOException: Error running exec(). Command: [shell, /system/bin/chmod, 0777, /storage/emulated/0/Android/data/com.example.andridutilproject/files/native] Working Directory: null Environment: null
任何建議,如何解決這個問題?
沒有'shell'可執行文件。你爲什麼試圖運行它? – 2014-10-30 22:22:55