3

I am trying to create NDK application dependent on OpenCV with new experimental gradle plugin in Android Studio but I can't really setup my build.gradle correctly.

My NDK setup in build.gradle looks like this:

/*
 * native build settings
 */
android.ndk {
    moduleName = "nonfree_jni"
    stl = "gnustl_static"
    cppFlags += "-I${opencv_path}".toString()    
}

where opencv_path is path to my OpenCV Android SDK (include directory)

If I open my .cpp file, the OpenCV classes and files are properly colored and everything looks OK but when I try to build project a lot of "undefined reference: cv::something" occurs.

I did not find any tutorial to run OpenCV in Android Studio (only that with manual ndk-build command) and don't really know how to fix this. Some stackoverflow post said that this errors happens when I don't point to OpenCV.mk in my Android.mk configuration but I obviously don't have this option.

Any ideas?

manfcas
  • 1,933
  • 7
  • 28
  • 47
Billda
  • 5,707
  • 2
  • 25
  • 44
  • 1
    Maybe [this](http://stackoverflow.com/questions/32171259/opencv-with-android-studio-1-3-using-new-gradle-undefined-reference) helps. – natario Sep 18 '15 at 15:01
  • @mvai thanks! It helped a lot. You should write it as answer and i will accept it – Billda Sep 18 '15 at 15:26
  • I know nothing about android-ndk and I am not able to interpret that (bad quality) answer :-) just did the search for you. – natario Sep 18 '15 at 15:30
  • This is not only duplicate, it's outdated. Android Studio 2.3 has integrated **ndk-build** to fully resolve such issues. – Alex Cohn Jul 01 '17 at 10:28

0 Answers0