Search code examples
javaandroidcommand-lineaapt

ERROR: input directory 'Files' does not exist


need to build the R.java file from resource using the command line. I do this using the following Java program. I get the

ERROR: input directory 'Files' does not exist

here is my code can anyone help which file directory is missing. or why this error is popped up.

public static String ProjectPath = "C:\\Users\\Muzammil-Husnain\\testing\\Soothing-snow-fall";
public static String ANDROID_HOME = "C:\\\"Program Files (x86)\"\\Android\\android-sdk";

public static void generateRfile() {
    try {
        File projectDirectoryFile = new File(ProjectPath);
        String command = "aapt package -v -f -m "+
        " -S \""+projectDirectoryFile.getCanonicalPath()+"\\res\"" +
        " -J \""+projectDirectoryFile.getCanonicalPath()+"\\gen\"" +
        " -M \""+projectDirectoryFile.getCanonicalPath()+"\\AndroidManifest.xml\"" +
        " -I C:\\\"Program Files (x86)\"\\Android\\android-sdk\\platforms\\android-21\\android.jar\"";
        System.out.println("Directory Path : "+projectDirectoryFile.getCanonicalPath());
        System.out.println(command);
        ProcessBuilder processBuilder = new ProcessBuilder("cmd.exe", "/c", command);
        processBuilder.redirectErrorStream(true);
        Process process = processBuilder.start();
        BufferedReader r = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line;
        while (true) {
            line = r.readLine();
            if (line == null) {
                break;
            }
            System.out.println(line);
        }

    } catch (IOException ex) {
        Logger.getLogger(RunApplicationOnPrject.class.getName()).log(Level.SEVERE, null, ex);
    }
}

Here is The Directory


Solution

  • I found Error

    " -I C:\\\"Program Files (x86)\"\\Android\\android-sdk\\platforms\\android-21\\android.jar\"";

    This Line was missing starting quote of the URL, while it contains ending quoteI fixed error by including quote like this:

    " -I \"C:\\\"Program Files (x86)\"\\Android\\android-sdk\\platforms\\android-21\\android.jar\""
    

    Thanks to @Prashant and @Laszlo Lugosi for your attention.