Ask Your Question
0

sync failed when adding opencv as a dependence for my app

asked 2019-10-13 23:13:51 -0600

ARYL518 gravatar image

updated 2019-10-13 23:46:38 -0600

berak gravatar image

Hi, I want to use opencv-4.1.1-android-sdk in my app. My android studio version is 3.3.2 and sdk api is 28. I use Windows. I copied all libs under native/libs to my jniLibs folder. Then I import new module by specify the sdk/java folder and it succeed. However, when I open module setting and add dependence, I got sync error as following:

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :opencvjavasupport. Show Details Affected Modules: app

Any help are very appreciated.

Thanks.

YL

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-10-14 01:57:53 -0600

LBerger gravatar image

updated 2019-10-14 06:13:57 -0600

You must follow instruction in opencv/sdk/build.gradle

// This file is located in <OpenCV-android-sdk>/sdk directory (near 'etc', 'java', 'native' subdirectories)
//
// Add module into Android Studio application project:
//
// - Android Studio way:
//   (will copy almost all OpenCV Android SDK into your project, ~200Mb)
//
//   Import module: Menu -> "File" -> "New" -> "Module" -> "Import Gradle project":
//   Source directory: select this "sdk" directory
//   Module name: ":opencv"
//
// - or attach library module from OpenCV Android SDK
//   (without copying into application project directory, allow to share the same module between projects)
//
//   Edit "settings.gradle" and add these lines:
//
//   def opencvsdk='<path_to_opencv_android_sdk_rootdir>'
//   // You can put declaration above into gradle.properties file instead (including file in HOME directory),
//   // but without 'def' and apostrophe symbols ('): opencvsdk=<path_to_opencv_android_sdk_rootdir>
//   include ':opencv'
//   project(':opencv').projectDir = new File(opencvsdk + '/sdk')
//
//
//
// Add dependency into application module:
//
// - Android Studio way:
//   "Open Module Settings" (F4) -> "Dependencies" tab
//
// - or add "project(':opencv')" dependency into app/build.gradle:
//
//   dependencies {
//       implementation fileTree(dir: 'libs', include: ['*.jar'])
//       ...
//       implementation project(':opencv')
//   }
//
edit flag offensive delete link more

Comments

1

It works. Many thanks.

ARYL518 gravatar imageARYL518 ( 2019-10-16 07:07:40 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-10-13 23:13:51 -0600

Seen: 2,756 times

Last updated: Oct 14 '19