8

I have an Android app that uses OpenCV's Java wrapper for image processing. To add OpenCV to the project, I had to add the following line to gradle.properties:

android.useDeprecatedNdk=true

This had been working fine without any warnings or errors (that I know of) up until I updated my Android Studio and Gradle after a long time (I'm using Gradle 2.2.2 and Android Studio 2.2.2 now). Now when I build my app, I get the following warnings on the messages window:

Warning:Native C/C++ source code is found, but it seems that NDK option is not configured. Note that if you have an Android.mk, it is not used for compilation. The recommended workaround is to remove the default jni source code directory by adding:

Warning:Deprecated NDK integration enabled by useDeprecatedNdk flag in gradle.properties will be removed from Android Gradle plugin soon.

Even though the build is successful at this time, as the second warning informs, this is highly likely to cause some trouble in the future, so I want to resolve them as soon as possible before things go sideways.

Does anyone know how to get resolve these warnings? Or are there any other way to import OpenCV to an Android project, other than adding all the compiled code (the .so files) and setting the flag I mentioned earlier? Any help on this will be appreciated.

halileohalilei
  • 2,220
  • 2
  • 25
  • 52

2 Answers2

0

I would suggest to migrate over to using the native support with cmake. You could check the link which provides a step-by-step tutorial to add OpenCV using cmake via the following link.

You're code should stay the same without any changes, only necessary action is to figure out how to include them within the build process using CMakeLists.txt.

ahasbini
  • 6,761
  • 2
  • 29
  • 45
0

In the project pane, right click your app (in my React Native project it's the "app" catalog), and select "Link C++ project with gradle".

Now you must find the Android.mk file - it should be already generated in your_app/app/build/intermediates/ndk/debug/

Ziarno
  • 7,366
  • 5
  • 34
  • 40