title: How to add OpenCV in Flutter Plugin
body: <p>I am working on a flutter project where I have to detect edges of the objects. I have searched for existing plugins but couldn't find any. I am planning to use OpenCV for edge detection.</p>
  
  <p>I have created a flutter plugin from Android Studio. This is the plugin structure.</p>
  
  <p><a href="https://i.stack.imgur.com/nEQL9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nEQL9.png" alt="enter image description here"></a></p>
  
  <p>I have downloaded the OpenCV for Android from here - <a href="https://sourceforge.net/projects/opencvlibrary/files/opencv-android/3.4.3/opencv-3.4.3-android-sdk.zip/download" rel="noreferrer">opencv-3.4.3-android-sdk</a> and extracted.</p>
  
  <p><a href="https://i.stack.imgur.com/v9Uie.png" rel="noreferrer"><img src="https://i.stack.imgur.com/v9Uie.png" alt="enter image description here"></a></p>
  
  <p>I have imported the java folder from OpenCV SDK as the module to the Android Project of the flutter plugin.</p>
  
  <p>This is how my android project (flutter plugin) <strong>build.gradle</strong> looks like</p>
  
  <pre><code>group 'com.xxxx.xxxxx'
  version '1.0-SNAPSHOT'
  
  buildscript {
      ext.kotlin_version = '1.2.30'
      repositories {
          google()
          jcenter()
      }
  
      dependencies {
          classpath 'com.android.tools.build:gradle:3.1.2'
          classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
      }
  }
  
  rootProject.allprojects {
      repositories {
          google()
          jcenter()
      }
  }
  
  apply plugin: 'com.android.library'
  apply plugin: 'kotlin-android'
  apply plugin: 'kotlin-android-extensions'
  
  android {
      compileSdkVersion 27
  
      sourceSets {
          main.java.srcDirs += 'src/main/kotlin'
      }
      defaultConfig {
          minSdkVersion 16
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      lintOptions {
          disable 'InvalidPackage'
      }
  }
  
  dependencies {
      implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
      implementation 'com.android.support:appcompat-v7:27.1.1'
      implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
  
      implementation project(':openCVLibrary343')
      compileOnly files('templibs/flutter.jar')
  }
  </code></pre>
  
  <p>This is how my opencv <strong>build.gradle</strong> looks like</p>
  
  <pre><code>apply plugin: 'com.android.library'
  
  android {
      compileSdkVersion 27
      buildToolsVersion "28.0.3"
  
      defaultConfig {
          minSdkVersion 8
          targetSdkVersion 21
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
          }
      }
  }
  </code></pre>
  
  <p>This is how the <strong>settings.gradle</strong> of the Android project(flutter plugin) looks like</p>
  
  <pre><code>rootProject.name = 'flutter_plugin'
  include ':openCVLibrary343'
  </code></pre>
  
  <p>When I am trying to run the example app that is created by the flutter plugin template I am getting below error.</p>
  
  <p>Launching lib\main.dart on Nexus 6P in debug mode...
  Initializing gradle...
  Resolving dependencies...
  * Error running Gradle:
  Exit code 1 from: C:\Users\xxxxx\Documents\flutter_plugin\example\android\gradlew.bat app:properties:</p>
  
  <p>FAILURE: Build failed with an exception.</p>
  
  <ul>
  <li><p>Where:
  Build file 'C:\Users\xxxx\Documents\flutter_plugin\android\build.gradle' line: 48</p></li>
  <li><p>What went wrong:
  A problem occurred evaluating project ':flutter_plugin'.</p>
  
  <blockquote>
    <p>Project with path ':openCVLibrary343' could not be found in project ':flutter_plugin'.</p>
  </blockquote></li>
  <li><p>Try:
  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.</p></li>
  <li><p>Get more help at <a href="https://help.gradle.org" rel="noreferrer">https://help.gradle.org</a></p></li>
  </ul>
  
  <p>BUILD FAILED in 1s</p>
  
  <p>Finished with error: Please review your Gradle project setup in the android/ folder.</p>