Wednesday, May 5, 2021

gradle sync failed: could not set process working directory

          gradle sync failed: could not set process working directory

The ProcessBuilder class provides methods for creating and configuring operating system

processes. Each ProcessBuilder instance allows us to manage a collection of process attributes.

We can then start a new Process with those given attributes.

Here are a few common scenarios where we could use this API:

  • Find the current Java version
  • Set-up a custom key-value map for our environment
  • Change the working directory of where our shell command is running
  • Redirect input and output streams to custom replacements
  • Inherit both of the streams of the current JVM process 
  • We'll take a look at practical examples for each of these in later sections.

    But before we dive into the working code, let's take a look at what kind of functionality this API provides.

  • A few important points to keep in mind:

    • The arguments must be in the right order
    • Moreover, in this example, the default working directory and environment are used
    • We deliberately don't call process.waitFor() until after we've read the output because the output buffer might stall the process
    • We've made the assumption that the java command is available via the PATH variable
    • In this next example, we're going to see how to modify the working environment.

      But before we do that let's begin by taking a look at the kind of information we can find in the default environment:

      ProcessBuilder processBuilder = new ProcessBuilder();        
      Map<String, String> environment = processBuilder.environment();
      environment.forEach((key, value) -> System.out.println(key + value));

      This simply prints out each of the variable entries which are provided by default:

      PATH/usr/bin:/bin:/usr/sbin:/sbin
      SHELL/bin/bash
      ...

      Now we're going to add a new environment variable to our ProcessBuilder object and run a command to output its value:

      1. Firstly it shows that upgrade your android version. Target version is not supported.
        [My version was 3.5.3 .After getting this instruction i have upload it to 3.6.2]

      2. Then goes to build and it shows :
        Deprecated Gradle features ware used in this build, make it incompatible with Gradle 7.0

      Beside this IDE Re-commanded for "Android Gradle Plugin is ready to update".

      1. After update the Gradle when goes to build then it takes long time showing "Download bikram-sambat:1.1.0" and after that time shows below error:

      Executing tasks: [:collect_app:assembleDebug] in project blah

      FAILURE: Build failed with an exception.

      • What went wrong:
        Could not determine the dependencies of task ':collect_app:compileDebugJavaWithJavac'.

      Could not resolve all task dependencies for configuration ':collect_app:debugCompileClasspath'.
      Could not resolve bikramsambat:bikram-sambat:1.1.0.
      Required by:
      project :collect_app
      Skipped due to earlier error
      Could not resolve bikramsambat:bikram-sambat:1.1.0.

      build.gradle

      implementation 'org.apache.directory.studio:org.apache.commons.io:2.4
      api group: 'commons-io', name: 'commons-io', version: '2.6'

      Then Sync the build.gradle.
      But still problem exists.

      ERROR:

      collect_app\src\main\java\org\odk\collect\android\activities\FormEntryActivity.java:71: error: cannot find symbol
      import org.apache.commons.io.IOUtils;
      ^

      symbol: class IOUtils 






0 Comments: