An exercise in frustration

Hi guys,
I have not been so frustrated in long time. After a full day, I am still unable to compile an hello world in Android.

OpenCV for android 4.7.0 as downloaded
Android Studio Flamingo | 2022.2.1
Installed multiple SDK version, SDK built tools, NDK, command line tools, platform tools + some irrelevant extras.
Successfully tested a simple camera capture program using only android (not opencv).

Followed the tutorial:

However, I am unable to get it compiled:
error: package org.opencv.engine does not exist
import org.opencv.engine.OpenCVEngineInterface;

I found hundred of “solutions” on the internet. NONE of them works.
Ended up copying all the opencv java into the project,
i have the whole org/opencv/ tree in main, i have added the jniLibs folder, fixed version inconsistencies in gradle files etc…

Still, nothing works.
I was assuming that maybe I need to compile the opencv sdk.
Attempting to import the opencv/sdk in Android Studio to see if it compile. It does not:

A problem occurred evaluating root project ‘sdk’.

Plugin with id ‘com.android.library’ not found.

Questions:

  • The android packet is ready to go or need compiled ?
  • How to get OpenCV to compile in Android Studio, if this is the problem?
  • If no, any hints to alleviate a nerve-racking experience ?

Tnx.

You could have a try to add “android.defaults.buildfeatures.aidl=true” to the gradle.properties. to enable the aidl buildfeature.
ref: BuildFeatures  |  Android Developers

1 Like

Thank you very much Henry.
That is a very good piece of info. It fixedthat point,

Now, I advanced to the next frustration :grin:

error: cannot find symbol import org.opencv.BuildConfig;

No advice found by Google helped so far either.

Just in case somebody else have the org.opencv.BuildConfig; issue, I was able to pass that by adding:

buildFeatures {
    buildConfig true
}

in build.gradle for opencv.

Android is so frustrating … :frowning:

1 Like

recent updates, please take a look:

thank you so much. This saved me after 3 hours of searching all over.