title: Android Studio 2.2.3 cannot find <vector>
body: <h2>Configuration</h2>
  <p><strong>Operating system</strong>: Ubuntu 16.04</p>
  <p><strong>Android Studio Version</strong>: 2.2.3</p>
  <h2>Key code</h2>
  <p><code>~/project/build.gradle</code>:</p>
  <pre><code>buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:2.2.3'
        }
    }
    ...
  </code></pre>
  <p><code>~/project/library/build.gradle</code>:</p>
  <pre><code>apply plugin: 'com.android.library'
  
  android {
      ...
  
      defaultConfig {
          ...
  
          externalNativeBuild {
              cmake {
                  arguments '-DANDROID_TOOLCHAIN=clang',
                          '-DANDROID_STL=gnustl_static'
                       // I also tried '-DANDROID_STL=gnustl_shared', result is same
              }
          }
      }
  
      externalNativeBuild {
          cmake {
              path &quot;src/main/cpp/CMakeLists.txt&quot;
          }
      }
  
      ...
  }
  </code></pre>
  <p><code>~/project/app/build.gradle</code>:</p>
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      ...
  }
  
  dependencies {
      ...
      compile project(':library')
      ...
  }
  </code></pre>
  <p><code>~/project/settings.gradle</code></p>
  <pre><code>include ':app', ':library'
  </code></pre>
  <p><code>~/project/library/src/main/cpp/test.h</code>:</p>
  <pre><code>#include &lt;vector&gt;   // vector is red, says &quot;cannot find vector&quot;
  #include &lt;stdint.h&gt;
  
  class test {
  
  private:
      std::vector&lt;int32_t&gt; array;  // std is red, says &quot;can't resolve container std&quot;
  };
  </code></pre>
  <h3>Description of problem</h3>
  <p>In file <code>~/project/library/src/main/cpp/test.h</code>, <code>vector</code> in <code>#include &lt;vector&gt;</code> is red.
  When I move the mouse over it, it will popup a window which says <code>Cannot find 'vector'</code>.
  <code>std</code> in <code>std::vector&lt;int32_t&gt;</code> is also red. I move the mouse over it and it says <code>Can't resolve container 'std'</code>.</p>
  <p>This project has no compile error. It can be compiled successfully and installed on my phone. The problem is it has a syntax error. I don't have code completion on some variables, like <code>array</code> in <code>test.h</code>.</p>
  <h3>Some information I find</h3>
  <p>I imported project <a href="https://github.com/googlesamples/android-ndk/tree/master/teapots" rel="nofollow noreferrer">teapots</a> which contains <code>#include &lt;vector&gt;</code>.
  Android Studio did resolve <code>vector</code> and <code>std</code> symbol for this project.</p>
  <h3>My question</h3>
  <p>What did I do wrong? Why does project <a href="https://github.com/googlesamples/android-ndk/tree/master/teapots" rel="nofollow noreferrer">teapots</a> not have this problem?
  What's the key difference between my project and <code>teapots</code> that makes the latter one able to resolve <code>vector</code> and <code>std</code> but mine not?</p>
  <hr />
  <h2>Update</h2>
  <p>I created a new project in Android Studio. In step 1 of the new project wizard, I checked <code>include C++ Support</code>. In the last step, I kept the default <code>Toolchain Default</code> for <code>C++ Standard</code> option. After I clicked the <code>finish</code> button, Android Studio automatically created the file <code>native-lib.cpp</code> for me. I added code <code>#include &lt;vector&gt;</code> in line 3 in this file. This time Android Studio resolved symbol <code>vector</code> correctly. Then I created a new module library <code>mylibrary</code> for this project, and in there I added a <code>cpp</code> folder and <code>test.h</code> and it also resolved the symbol <code>vector</code>(<code>mylibrary</code> module's <code>build.gradle</code> had been correctly added CMake stuff by me). But my problem is I need to add <code>vector</code> to my existing project, and my existing project can't resolve the symbol <code>vector</code>.</p>