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

🐛 [firebase_messaging] cannot find symbol FirebaseMessagingPlugin #3914

Closed
haliliceylan opened this issue Oct 19, 2020 · 2 comments · Fixed by #4012
Closed

🐛 [firebase_messaging] cannot find symbol FirebaseMessagingPlugin #3914

haliliceylan opened this issue Oct 19, 2020 · 2 comments · Fixed by #4012
Labels
Needs Attention This issue needs maintainer attention. type: bug Something isn't working

Comments

@haliliceylan
Copy link

Bug report

Describe the bug
I followed Steps to reproduce and i get it this error

**project-path**/android/app/src/main/java/*package-name*/Application.java:18: error: cannot find symbol
      FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
      ^
  symbol:   variable FirebaseMessagingPlugin
  location: class Application
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* 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

Steps to reproduce

Steps to reproduce the behavior:

  1. Apply this guide https://firebase.flutter.dev/docs/migration/
  2. Go to and apply this fix [firebase_messaging] Application.java:18: error: incompatible types: PluginRegistry cannot be converted to FlutterEngine GeneratedPluginRegistrant.registerWith(registry); #1904
  3. "flutter run"
  4. See error or incorrect behavior

Expected behavior

Build application without error.


Additional context

Application.java content

Click To Expand
package *package-name*;

import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;

public class Application extends FlutterApplication implements PluginRegistrantCallback {
  @Override
  public void onCreate() {
    super.onCreate();
    FlutterFirebaseMessagingService.setPluginRegistrant(this);
  }

  @Override
  public void registerWith(PluginRegistry registry) {
      FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
  }
}

android/app/build.gradle content

Click To Expand
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'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"


def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
apply plugin: 'com.google.firebase.crashlytics'
android {
    compileSdkVersion 28

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

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "*package-name*"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }

   signingConfigs {
       release {
           keyAlias keystoreProperties['keyAlias']
           keyPassword keystoreProperties['keyPassword']
           storeFile file(keystoreProperties['storeFile'])
           storePassword keystoreProperties['storePassword']
       }
   }
   buildTypes {
       release {
           signingConfig signingConfigs.release

            minifyEnabled true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
       }
   }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.multidex:multidex:2.0.1'
    // implementation 'com.google.firebase:firebase-analytics:17.2.0'
    // testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-messaging:20.3.0'
}

configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.1, on Mac OS X 10.15.5 19F101, locale en-TR)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.50.1)
[✓] Connected device (1 available)

• No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 2.10.1
Flutter SDK 1.22.1
*app-name* 1.0.68+68

dependencies:
- animations 1.1.2 [flutter]
- audioplayers 0.16.1 [uuid path_provider flutter flutter_web_plugins]
- connectivity 0.4.9+3 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web]
- cupertino_icons 1.0.0
- device_id 0.2.0 [flutter]
- dio 3.0.10 [http_parser path]
- dotted_border 1.0.6 [flutter path_drawing]
- double_back_to_close_app 1.2.0 [flutter]
- expandable 4.1.4 [flutter]
- firebase_core 0.5.0+1 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_crashlytics 0.2.1+1 [flutter stack_trace firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface]
- firebase_database 4.1.1 [flutter firebase_core]
- firebase_messaging 7.0.3 [meta flutter firebase_core]
- firebase_performance 0.4.0+2 [flutter firebase_core]
- firebase_remote_config 0.4.0+2 [flutter firebase_core]
- flushbar 1.10.4 [flutter]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_cupertino_date_picker 1.0.26+2 [flutter]
- flutter_facebook_login 3.0.0 [flutter collection]
- flutter_html 1.0.2 [html csslib css_colors video_player chewie webview_flutter chewie_audio flutter_svg flutter]
- flutter_inappwebview 4.0.0+4 [flutter uuid mime]
- flutter_local_notifications 2.0.0+1 [flutter platform flutter_local_notifications_platform_interface timezone]
- flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math]
- fluttertoast 7.1.1 [flutter flutter_web_plugins]
- font_awesome_flutter 8.10.0 [flutter]
- giffy_dialog 1.8.0 [flutter flare_flutter]
- google_sign_in 4.5.4 [google_sign_in_platform_interface flutter meta google_sign_in_web]
- http 0.12.2 [http_parser path pedantic]
- image 2.1.18 [archive xml meta]
- image_picker 0.6.7+11 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- in_app_purchase 0.3.4+12 [async collection flutter json_annotation meta]
- intl 0.16.1 [path]
- launch_review 2.0.0 [flutter]
- multi_image_picker 4.7.14 [flutter meta]
- package_info 0.4.3 [flutter]
- rate_my_app 0.7.2 [shared_preferences smooth_star_rating pedantic flutter]
- rxdart 0.24.1
- sentry 3.0.1 [http meta stack_trace usage pedantic]
- share 0.6.5+2 [meta mime flutter]
- shared_preferences 0.5.12 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- sign_in_with_apple 2.5.2 [meta flutter]
- smooth_star_rating 1.1.1 [flutter]
- super_tooltip 0.9.0 [flutter]
- url_launcher 5.7.2 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- web_socket_channel 1.1.0 [async crypto stream_channel]

dev dependencies:
- flutter_launcher_icons 0.8.1 [image args yaml path]
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- archive 2.0.13 [crypto args path]
- args 1.6.0
- async 2.5.0-nullsafety.1 [collection]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- chewie 0.9.10 [open_iconic_flutter video_player wakelock flutter]
- chewie_audio 1.0.0+1 [open_iconic_flutter video_player screen flutter]
- clock 1.1.0-nullsafety.1
- collection 1.15.0-nullsafety.3
- connectivity_for_web 0.3.1+2 [connectivity_platform_interface flutter_web_plugins flutter]
- connectivity_macos 0.1.0+5 [flutter]
- connectivity_platform_interface 1.0.6 [flutter meta plugin_platform_interface]
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- css_colors 1.0.2 [flutter]
- csslib 0.16.2 [source_span]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- firebase 7.3.0 [http http_parser js]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- firebase_crashlytics_platform_interface 1.1.1 [flutter meta collection firebase_core plugin_platform_interface]
- flare_dart 2.3.4
- flare_flutter 2.0.6 [flutter flare_dart meta]
- flutter_local_notifications_platform_interface 2.0.0 [flutter plugin_platform_interface]
- flutter_plugin_android_lifecycle 1.0.11 [flutter]
- flutter_svg 0.18.1 [path_drawing xml vector_math meta flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- google_sign_in_platform_interface 1.1.2 [flutter meta quiver]
- google_sign_in_web 0.9.2 [google_sign_in_platform_interface flutter flutter_web_plugins meta js]
- html 0.14.0+4 [csslib source_span]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image_picker_platform_interface 1.1.1 [flutter meta http plugin_platform_interface]
- js 0.6.2
- json_annotation 3.1.0
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- mime 0.9.7
- open_iconic_flutter 0.3.0 [flutter]
- path 1.8.0-nullsafety.1
- path_drawing 0.4.1+1 [vector_math meta path_parsing flutter]
- path_parsing 0.1.4 [vector_math meta]
- path_provider 1.6.18 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+4 [flutter]
- path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+1 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- petitparser 3.1.0 [meta]
- platform 2.2.1
- plugin_platform_interface 1.0.3 [meta]
- process 3.0.13 [file intl meta path platform]
- quiver 2.1.3 [matcher meta]
- screen 0.0.5 [flutter]
- shared_preferences_linux 0.0.2+2 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+10 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 0.0.1+1 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- stack_trace 1.10.0-nullsafety.1 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- timezone 0.5.7 [path]
- typed_data 1.3.0-nullsafety.3 [collection]
- url_launcher_linux 0.0.1+1 [flutter]
- url_launcher_macos 0.0.1+8 [flutter]
- url_launcher_platform_interface 1.0.8 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.4+1 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+1 [flutter]
- usage 3.4.2 [path]
- uuid 2.2.2 [crypto convert]
- vector_math 2.1.0-nullsafety.3
- video_player 0.10.12+5 [meta video_player_platform_interface video_player_web flutter]
- video_player_platform_interface 2.2.0 [flutter meta]
- video_player_web 0.1.4 [flutter flutter_web_plugins meta video_player_platform_interface]
- wakelock 0.1.4+2 [flutter]
- webview_flutter 0.3.24 [flutter]
- win32 1.7.3 [ffi]
- xdg_directories 0.1.2 [meta path process]
- xml 4.5.1 [collection convert meta petitparser]
- yaml 2.2.1 [charcode collection string_scanner source_span]

@haliliceylan haliliceylan added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 19, 2020
@haliliceylan
Copy link
Author

i forgot import keyword, i open in android studio and imported now seems ok.

@erayhamurlu
Copy link

erayhamurlu commented Nov 17, 2020

i have same problem, how did you fixed?

@firebase firebase locked and limited conversation to collaborators Nov 21, 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. type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants