Ask Your Question
1

Importing OpenCV 4.X android SDK module into Android Studio

asked 2019-11-27 23:50:27 -0500

rtrahms gravatar image

updated 2019-12-06 07:12:15 -0500

Akhil Patel gravatar image

Android Studio 3.5 OpenCV Android SDK 4.1.1 and 4.1.2 I have followed numerous tutorials importing OpenCV 3.4.X Android SDK modules from source, but have not been able to do the same for OpenCV 4.X Android SDK modules. Has something changed that prevents this import?

The clues: After the import of opencv java folder into the AS project, I first noticed the usual gradle errors (seen in 3.4.X imports) did not appear. Also, when attempting to set up the dependency between the library and the app, I could not (ref: image).

Screenshots of the steps I take to import opencv module from source, then attempt to add the dependency to the app...

image description image description image description image description image description image description image description

<updated with="" solution=""> For some reason, the build.gradle file of the imported OpenCV-4.X Android SDK contains some problematic bits. Once I corrected those, I could set the dependency correctly. Main problem: first line of the OpenCV-4.X build.gradle file was apply plugin: 'com.android.application' when it should be apply plugin: 'com.android.library'. Correcting this and other items in the build.gradle file fixed the issue.

Thanks, Rob

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2019-11-28 08:50:34 -0500

Akhil Patel gravatar image

updated 2019-11-29 01:00:06 -0500

First of all you must import your opencv library as a module and than try to add dependency in your app.

file -> new -> import module

also your import module is library not a package or not a project otherwise it will not add in your project dependency. image description. image description. image description. image description. image description. image description. image description.

In above images shows the which path you have to select.

edit flag offensive delete link more

Comments

1

Try above path as your module and than add dependency to your app

Akhil Patel gravatar imageAkhil Patel ( 2019-11-29 00:29:51 -0500 )edit
1

another thing is that java package does not contain any buid.gradle file i mean java is not gradle build system so that's why it generate an error

Akhil Patel gravatar imageAkhil Patel ( 2019-11-29 00:45:12 -0500 )edit
1

see above steps shows that i have successfully add opencv dependency in my app

Akhil Patel gravatar imageAkhil Patel ( 2019-11-29 01:00:50 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-11-27 23:50:27 -0500

Seen: 85 times

Last updated: Nov 30