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.
I have created a flutter plugin from Android Studio. This is the plugin structure.
I have downloaded the OpenCV for Android from here - opencv-3.4.3-android-sdk and extracted.
I have imported the java folder from OpenCV SDK as the module to the Android Project of the flutter plugin.
This is how my android project (flutter plugin) build.gradle looks like
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')
}
This is how my opencv build.gradle looks like
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'
}
}
}
This is how the settings.gradle of the Android project(flutter plugin) looks like
rootProject.name = 'flutter_plugin'
include ':openCVLibrary343'
When I am trying to run the example app that is created by the flutter plugin template I am getting below error.
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:
FAILURE: Build failed with an exception.
Where: Build file 'C:\Users\xxxx\Documents\flutter_plugin\android\build.gradle' line: 48
What went wrong: A problem occurred evaluating project ':flutter_plugin'.
Project with path ':openCVLibrary343' could not be found in project ':flutter_plugin'.
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.
Get more help at https://help.gradle.org
BUILD FAILED in 1s
Finished with error: Please review your Gradle project setup in the android/ folder.



