AndroidStudio can't find OpenCV headers
<p>I want to try one of the sample codes shipped with SDK, namely "tutorial-2-mixedprocessing". I followed these steps:</p>

<p>1) Import Project -> selected tutorial directory</p>

<p>2) I named it “tutorial-2-mixedprocessing1”, left 3 options ticked (“Replace jars&amp;lib sources when possible” and “Create Gradle-style module names”) </p>

<p>3) <em>Warning: “NDK integration deprecated in the current plugin”</em> I clicked <em>“Set "android.useDeprecatedNdk=true" in gradle.properties to continue using the current NDK integration”</em></p>

<p>4) Import module ->  Selected java module which is in “C:\SDKs\OpenCV-android-sdk\sdk\java” in my case -> Left 3 checkbox ticked</p>

<p>5) <em>Error:Cause: failed to find target with hash string 'android-14' in: C:\Users\c010\AppData\Local\Android\Sdk Install missing platform(s) and sync project.</em> I changed compileSdkversion, buildToolsVersion and targetSdkVersion and synced. Error dissapeared. </p>

<p>6-7) Open module settings -> Dependencies Added Opencv module as module dependency. Added NDK location (“C:\SDKs\android-ndk-r12-beta2” in my case)</p>

<p>8) Build -> make project leads <em>Error:(2, 33) opencv2/core/core.hpp: No such file or directory</em></p>

<p>In Eclipse I would add some include paths, but I don’t know how to do it in Android Studio. I thought editing Android.mk could help:</p>

<p>My Android.mk was</p>

<pre><code>LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

ifdef OPENCV_ANDROID_SDK
  ifneq ("","$(wildcard $(OPENCV_ANDROID_SDK)/OpenCV.mk)")
    include ${OPENCV_ANDROID_SDK}/OpenCV.mk
  else
    include ${OPENCV_ANDROID_SDK}/sdk/native/jni/OpenCV.mk
  endif
else
  include ../../sdk/native/jni/OpenCV.mk
endif

LOCAL_MODULE    := mixed_sample
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS +=  -llog -ldl

include $(BUILD_SHARED_LIBRARY)
</code></pre>

<p>I changed it to plain absolute path</p>

<pre><code>LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include C:\SDKs\OpenCV-android-sdk\sdk\native\jni\OpenCV.mk

LOCAL_MODULE    := mixed_sample
LOCAL_SRC_FILES := jni_part.cpp
LOCAL_LDLIBS +=  -llog -ldl

include $(BUILD_SHARED_LIBRARY)
</code></pre>

<p>Didn’t help.</p>

<p>I added 'OPENCV_ANDROID_SDK := C:\SDKs\OpenCV-android-sdk\' before “ifdef ...” line, same result. </p>

<p>I added 'LOCAL_C_INCLUDES += C:\SDKs\OpenCV-android-sdk\sdk\native\jni\include' , same result.</p>

<p>I edited gradle file which looked like </p>

<pre><code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "org.opencv.samples.tutorial2"
        minSdkVersion 8
        targetSdkVersion 8

        ndk {
            moduleName "mixed_sample"
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile project(':openCVLibrary310')
}
</code></pre>

<p>I changed ndk bracket as follows: </p>

<pre><code>ndk {
    moduleName "mixed_sample"
    cFlags  += "-I${file("C:/SDKs/OpenCV-android-sdk/sdk/native/jni/include")}".toString()
}
</code></pre>

<p><em>Error:error: null-IC:\SDKs\OpenCV-android-sdk\sdk\native\jni\include: Invalid argument</em></p>

<p>It didn't accept cppFlags <em>Error:(14, 0) Could not find property 'cppFlags' on com.android.build.gradle.internal.dsl.NdkOptions_Decorated@797a42f2.</em></p>