Ask Your Question

Revision history [back]

The problem is explained here. Since Android 5.0 service intents must be explicit intents and the OpenCV library uses implicit intents in the AsyncServiceHelper.java (new Intent("org.opencv.engine.BIND")), so it doesn't work.

Changing the targetSDK is just a workaround for now, but eventually the source-code has to be changed in the future (@alexander-smorkalov might know more). The solution would be to change the Method initOpenCV to something like this:

public static boolean initOpenCV(String Version, final Context AppContext,
        final LoaderCallbackInterface Callback)
{
    AsyncServiceHelper helper = new AsyncServiceHelper(Version, AppContext, Callback);
    Intent explicitIntent = new Intent(AppContext, org.opencv.engine.???.class);
    if (AppContext.bindService(explicitIntent,
            helper.mServiceConnection, Context.BIND_AUTO_CREATE))
    {
        return true;
    }
    else
    {
        AppContext.unbindService(helper.mServiceConnection);
        InstallService(AppContext, Callback);
        return false;
    }
}

but since parts of OpenCV are built with the JNI, I don't know what to put there instead of the ??? because 'BIND' is just a placeholder it seems to me.

The problem is explained here. Since Android 5.0 service intents must be explicit intents and the OpenCV library uses implicit intents in the AsyncServiceHelper.java (new Intent("org.opencv.engine.BIND")), so it doesn't work.

Changing the targetSDK is just a workaround for now, but eventually the source-code has to be changed in the future (@alexander-smorkalov (Alex might know more). The solution would be to change the Method initOpenCV to something like this:

public static boolean initOpenCV(String Version, final Context AppContext,
        final LoaderCallbackInterface Callback)
{
    AsyncServiceHelper helper = new AsyncServiceHelper(Version, AppContext, Callback);
    Intent explicitIntent = new Intent(AppContext, org.opencv.engine.???.class);
    if (AppContext.bindService(explicitIntent,
            helper.mServiceConnection, Context.BIND_AUTO_CREATE))
    {
        return true;
    }
    else
    {
        AppContext.unbindService(helper.mServiceConnection);
        InstallService(AppContext, Callback);
        return false;
    }
}

but since parts of OpenCV are built with the JNI, I don't know what to put there instead of the ??? because 'BIND' is just a placeholder it seems to me.