rushio-consulting / flutter_camera_ml_vision

A flutter widget that show the camera stream and allow ML vision recognition on it, it allow you to detect barcodes, labels, text, faces...
MIT License
278 stars 107 forks source link

Could not find com.google.firebase:firebase-ml-vision #146

Open tnagasak opened 3 years ago

tnagasak commented 3 years ago

When I added flutter_camera_ml_vision to an existing project, I got the following error.

Execution failed for task ':app:checkDebugAarMetadata'.                 
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find com.google.firebase:firebase-ml-vision:.            
     Required by:                                                       
         project :app > project :firebase_ml_vision

I didn't know what caused it, so I copied the code (from the official website). After that, I tried to link firebase and added only flutter_camera_ml_vision, but I got the same error as above.

The main.dart is the same as the URL above, and the other files that I changed are as follows. The version of flutter_camera_ml_vision is 3.0.1. As a supplement, the ./gradlew command succeeds.

//android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.association_firebase">
   <application
        android:label="association_firebase"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">

            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />

            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <!-- add -->
        <meta-data
            android:name="com.google.firebase.ml.vision.DEPENDENCIES"
            android:value="ocr" />
    </application>
</manifest>
//android/app/build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
// add
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.example.association_firebase"
        minSdkVersion 21   // changed to 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
    // add
    dependencies {
        api 'com.google.firebase:firebase-ml-vision-image-label-model:19.0.0'
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    //add
    implementation platform('com.google.firebase:firebase-bom:28.0.1')
    //add
    implementation 'com.google.firebase:firebase-analytics'
}
//android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        //add
        classpath 'com.google.gms:google-services:4.3.8'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
ramirezleonel commented 3 years ago

I have the same problem

epitaciosoares commented 3 years ago

Any solution?

pablofr commented 3 years ago

I have the same problem

kw2019ltd commented 3 years ago

its not longer valid to use firebase-ml-vision

need to refactor it to use below: google_ml_kit: ^0.6.0

anitakr commented 3 years ago

I also had this issue, after some time I found out the problem was originating from the .iml file, called flutter_camera_ml_vision.iml in the example in this package. I tried switching mine out for theirs and then this error finally disappeared. Then I compared the two to find the issue.

barilki commented 3 years ago

Any solution?

ngant97 commented 3 years ago

help me solution

anitakr commented 3 years ago

I ended up using google_ml_kit

kw2019ltd commented 3 years ago

I ended up using google_ml_kit

can you share example

Lelelo1 commented 3 years ago

In the docs there is broken link to setup firebase, is that step that is missing - leading to this error?