title: Why is Android Studio ignoring my .bashrc file on OSX?
body: <p>I have downloaded a project that uses Android's ndk. The gradle file contains the lines:</p>
  
  <pre><code>task ndkBuild(type: Exec) {
      commandLine 'ndk-build', '-B', '-C', file('src/main/jni').absolutePath
  }
  </code></pre>
  
  <p>This works fine when running <code>./gradlew assembleDebug</code>. I have the following contents in my <code>~/.bashrc</code>:</p>
  
  <pre><code># Append android sdk paths and stuff.
  export ANDROID_HOME=/Users/gradha/instalacion_manual/android-sdk-r10-mac_x86
  #export ANDROID_NDK_ROOT=/Users/gradha/instalacion_manual/android-ndk-r8b
  export ANDROID_NDK_ROOT=/Users/gradha/instalacion_manual/android-ndk-r10e
  export NDK_PATH="${ANDROID_NDK_ROOT}"
  export NDK_HOME="${ANDROID_NDK_ROOT}"
  export PATH=$PATH:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:/Users/gradha/instalacion_manual/apache-maven-3.3.3/bin:"${ANDROID_NDK_ROOT}"
  </code></pre>
  
  <p>However, when I try to build the project from inside Android studio I get</p>
  
  <pre><code>process.internal.ExecException: A problem occurred starting process 'command 'ndk-build''
      at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:196)
      at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:325)
      at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:83)
      ... 1 more
  Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'ndk-build'
      at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
      at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
      at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:65)
      ... 1 more
  Caused by: java.io.IOException: Cannot run program "ndk-build" (in directory "/Users/gradha/project/questionity/archivo/SuperpoweredSDK/Android/CrossExample/app"): error=2, No such file or directory
      at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
      ... 3 more
  Caused by: java.io.IOException: error=2, No such file or directory
      ... 4 more
  </code></pre>
  
  <p>Which suggests that the <code>PATH</code> variable is not being set properly in the environment and not even the <code>ndk-build</code> process is able to run. <a href="https://stackoverflow.com/questions/29795388/how-to-set-ndk-build-path-in-osx-for-android-studio">Touching .bashrc is supposed to make this work</a>. Why does Android Studio not pick up the <code>PATH</code> environment variable specified in the <code>.bashrc</code> file?</p>
  
  <p><strong>EDIT PSEUDO ANSWER</strong>: Android Studio follows <a href="https://stackoverflow.com/a/7842725/172690">other development environments like Xcode</a> to avoid user personal configuration files altering the software build process. The correct workaround, <a href="https://stackoverflow.com/a/33737737/172690">like Alex mentions</a> is to read an external <code>local.properties</code> file with an <code>ndk.dir</code> variable pointing at the proper path, and source this variable to build a full path to <code>ndk-build</code> instead of relying on the environment's <code>PATH</code>. The <code>local.properties</code> file can be kept out of source control and be customised for each checkout.</p>