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

MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) on Android #3212

Closed
tomtaila opened this issue Aug 18, 2020 · 13 comments
Labels
Needs Attention This issue needs maintainer attention.

Comments

@tomtaila
Copy link

tomtaila commented Aug 18, 2020

I am getting the above error when calling Firebase.initializeApp() in my flutter code.
I have followed the documentation here: https://firebase.flutter.dev/docs

Here is my pubspec.yaml

name: moolla
description: Moolla - Flutter

publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+2

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^0.5.0
  cloud_firestore: ^0.14.0
  firebase_auth: ^0.18.0
  cupertino_icons: ^0.1.3

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true

  assets:
    - images/
  fonts:
    - family: BalooThambi2
      fonts:
        - asset: fonts/baloo_thambi2_m.ttf
        - asset: fonts/baloo_thambi2_r.ttf
        - asset: fonts/baloo_thambi2_b.ttf
        - asset: fonts/baloo_thambi2_sb.ttf
        - asset: fonts/baloo_thambi2_xb.ttf

Here is my flutter code:

import 'dart:core';
import 'dart:developer';

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(
    FutureBuilder(
      future: Firebase.initializeApp(),
      builder: (context, snapshot) {
        // Check for errors
        if (snapshot.hasError) {
          log(snapshot.error.toString());
          return Container(color: Colors.red,);
        }

        // Once complete, show your application
        if (snapshot.connectionState == ConnectionState.done) {
          return Container(color: Colors.green);
        }

        // Otherwise, show something whilst waiting for initialization to complete
        return Container(color: Colors.blue,);
      },
    ),
  );
}

Here are the relevant part of my .gradle (app) file:

plugins {
    id "com.android.application"
    id "com.google.gms.google-services"
    id "kotlin-android"
    id "kotlin-android-extensions"
}

Here is my project gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.0-alpha07'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
    }
}

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

and my Application class extension:

class MyApp : FlutterApplication() {
    override fun onCreate() {
        super.onCreate()
    }
}

Finally, here is my flutter doctor -v output:

[✓] Flutter (Channel beta, 1.20.2, on Mac OS X 10.15.5 19F96, locale en-US)
    • Flutter version 1.20.2 at /Users/tom/development/flutter
    • Framework revision bbfbf1770c (5 days ago), 2020-08-13 08:33:09 -0700
    • Engine revision 9d5b21729f
    • Dart version 2.9.1

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/tom/Library/Android/sdk
    • Platform android-30, build-tools 30.0.1
    • Java binary at: /Users/tom/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6626763/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio
    • Android Studio at /Applications/Android Studio 4.2 Preview.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Android Studio (version 4.0)
    • Android Studio at /Users/tom/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/193.6626763/Android Studio.app/Contents
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.48.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.13.2

[✓] Connected device (3 available)
    • Pixel 3 (mobile) • 89HX09YAJ  • android-arm64  • Android 11 (API 30)
    • Web Server (web) • web-server • web-javascript • Flutter Tools
    • Chrome (web)     • chrome     • web-javascript • Google Chrome 84.0.4147.125

As far as I can tell I have done everything correctly according to the docs.

@bhanuka96
Copy link

same issue after upgrading to 0.14.0

@bhanuka96
Copy link

bhanuka96 commented Aug 18, 2020

I fixed that issue after adding this line await Firebase.initializeApp();

And also you need to add this on your pubspec firebase_core: ^0.5.0

/// Requires that a Firestore emulator is running locally.
/// See https://firebase.flutter.dev/docs/firestore/usage#emulator-usage
bool USE_FIRESTORE_EMULATOR = false;

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  if (USE_FIRESTORE_EMULATOR) {
    FirebaseFirestore.instance.settings = Settings(
        host: 'localhost:8080', sslEnabled: false, persistenceEnabled: false);
  }
  runApp(FirestoreExampleApp());
}

@TahaTesser
Copy link

Hi @tomtaila
Does this above #3212 (comment) solves your issue?

If the problem persist, Can you please provide your flutter doctor -v and flutter run --verbose logs, and a minimal complete reproducible code sample?
Thank you

@TahaTesser TahaTesser added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Aug 18, 2020
@tomtaila
Copy link
Author

@TahaTesser I updated the code snippets in my initial post above and made it as bare bones as possible. It literally does nothing but try to initialize firebase.
I also removed a bunch of dependencies and posted the flutter doctor -v results.
The #3213 comment did not help unfortunately.

Also, I posted this stack overflow issue: https://stackoverflow.com/questions/63462069/missingpluginexceptionno-implementation-found-for-method-firebaseinitializecor?noredirect=1#comment112245507_63462069 and it looks like others are also having this problem.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Aug 18, 2020
@TahaTesser TahaTesser removed the Needs Attention This issue needs maintainer attention. label Aug 19, 2020
@TahaTesser
Copy link

TahaTesser commented Aug 19, 2020

Hi @tomtaila
Running your code sample in a new project using the following packages, no issues

Screenshot_1597833057

  firebase_auth: ^0.18.0
  firebase_core: ^0.5.0
buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.3'
    }
}

Please create new project flutter create myapp and make sure to use com.android.tools.build:gradle:3.5. since 'com.android.tools.build:gradle:4.2.0-alpha07 isn't officially supported yet and try again

@TahaTesser TahaTesser added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Aug 19, 2020
@PeterHdd
Copy link

In the following link you can find four examples of calling initializeApp() working perfectly:

https://stackoverflow.com/a/63492262/7015400

Using the following android/build.gradle:

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

    dependencies {
            // Add this line
        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

@tomtaila
Copy link
Author

@TahaTesser I restarted a fresh project and used v 3.5.0 of gradle build tools. It works as you said, thank you!
@PeterHdd Thank you too!

@tomtaila tomtaila reopened this Aug 29, 2020
@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Aug 30, 2020
@mhmmdlkts
Copy link

I deleted the Pods Directory and the Podfile, Podfile.lock, Runner.xcworkspace files. That solved my problem.

@codaveto-zz
Copy link

I am still having this issue with some others and creating a new project to me doesn't sound like a viable solution can someone please reopen this?

@tomtaila
Copy link
Author

I'm pretty sure that it's not actually a Firebase problem. I think what happens is that if you have some other plugin which fails then this error comes up (hence masking the real culprit). Actually, it seems to me that if ANY plugins fail, they all fail (since this is a Plugin library this fails too).
Check your project isn't using some other plugin that is causing the problem.

@codaveto-zz
Copy link

Thank you for your response.
I ended up creating a new project carefully copying firebase and multiple other packages from the original project. After that I copied every single file in lib/android along with their respective configurations in build.gradle and manifests. For iOS I just copied the entire project and that worked immediately.

All seems to work now in the 'new' project. Still completely unsure what the culprit was since I've copied the exact project over to a new one. Anyway hope this helps anyone with this issue. I've wasted five days on this 😄, I wish you not the same whoever you are.

👋

@Gregga16
Copy link

I had the same problem. When i removed some lines from the MainActivity it works.

import io.flutter.app.FlutterActivity -> didn't work.

import io.flutter.embedding.android.FlutterActivity -> works;

MainActivity looks like:

packagecom.yourdomain

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() { }

@ndhbr
Copy link

ndhbr commented Sep 24, 2020

I only have this bug under iOS 14.0. Unfortunately I can't get rid of it. I have tried Stable 1.20.4 and 1.22.0-12.1.pre beta. Neither of them worked.

@firebase firebase locked and limited conversation to collaborators Sep 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Attention This issue needs maintainer attention.
Projects
None yet
Development

No branches or pull requests

9 participants