由以下原因引起:java.io.IOException:无法运行程序“ g ++”:错误= 13,权限被拒绝

时间:2019-01-30 06:41:09

标签: android

无法解决

我已经尽力了

 try {
            process = Runtime.getRuntime().exec("chmod -777 YourAndroidStudioFolder"+
            "chmod +x /User/Library/Android/sdk/build-tools/23.0.1/aapt\\n\" +\n" +
                    "                        \"chmod +x /User/Library/Android/sdk/build-tools/23.0.1/dx\\n\" +\n" +
                    "                        \"chmod +x /User/Library/Android/sdk/build-tools/23.0.1/zipalign"+"cat config.cpp");
            dataOutputStream = new DataOutputStream(process.getOutputStream());
            //dataOutputStream.writeBytes("g++ config.cpp -o a.out");
            //dataOutputStream.writeBytes("exit\n");
            dataOutputStream.flush();
            process.waitFor();
            Log.v("SUccess", "works");
        } catch (Exception e) {
            Log.v("Error:",e.toString());
        } finally {
            try {
                if (dataOutputStream != null) {
                    dataOutputStream.close();
                }
                process.destroy();
            } catch (Exception e) {
            }
        }

此代码有效,但

process = Runtime.getRuntime().exec("g++ config.cpp -o a.out");

这不起作用,不断出现错误13。

1 个答案:

答案 0 :(得分:0)

尝试检查您实际尝试使用的g++并检查权限。

 ls -l `which g++`