来自ProcessBuilder的Android InputStream:readLine()返回null

时间:2014-01-16 09:01:20

标签: java android null processbuilder

我正在构建基于以下内容的Android应用:https://code.google.com/p/ics-openvpn/ 但是,签名和导出后,一些原始代码无效:

private void startOpenVPNThreadArgs(String[] argv, Map<String, String> env) {
        LinkedList<String> argvlist = new LinkedList<String>();

        Collections.addAll(argvlist, argv);

        ProcessBuilder pb = new ProcessBuilder(argvlist);
        // Hack O rama

        String lbpath = genLibraryPath(argv, pb);

        pb.environment().put("LD_LIBRARY_PATH", lbpath);

        // Add extra variables
        for(Entry<String,String> e:env.entrySet()){
            pb.environment().put(e.getKey(), e.getValue());
        }
        pb.redirectErrorStream(true);
        try {
            mProcess = pb.start();
            // Close the output, since we don't need it
            mProcess.getOutputStream().close();
            InputStream in = mProcess.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(in));

            while(true) {
                String logline = br.readLine();
                if(logline==null) {
                    System.out.println("logline == null");
                    return;
                }

我不断得到:logline == null,然后连接中断了。没有例外 参数env是一个空地图! 这都是原始代码,我真的不知道在哪里看,因为没有评论或JavaDoc。任何人都可以帮我解决这个问题吗? 感谢

1 个答案:

答案 0 :(得分:0)

当我意识到它试图编写一些不存在的二进制文件时,发现了这里的问题:s