Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tnagasak opened this issue May 19, 2021 · 10 comments
Open

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

tnagasak opened this issue May 19, 2021 · 10 comments

Comments

@tnagasak
Copy link

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
Copy link

I have the same problem

@epitaciosoares
Copy link

Any solution?

@pablofr
Copy link

pablofr commented Jun 11, 2021

I have the same problem

@kw2019ltd
Copy link

its not longer valid to use firebase-ml-vision

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

@anitakr
Copy link

anitakr commented Jun 15, 2021

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
Copy link

barilki commented Jun 19, 2021

Any solution?

@ngant97
Copy link

ngant97 commented Jul 1, 2021

help me solution

@anitakr
Copy link

anitakr commented Jul 1, 2021

I ended up using google_ml_kit

@kw2019ltd
Copy link

I ended up using google_ml_kit

can you share example

@Lelelo1
Copy link

Lelelo1 commented Aug 16, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants