Description
I add firebase messaging version 6.0.16 from the pub.dev website and follow the instructions. When I add the java class Application.java I get various errors when import io.flutter.pluggins.firebasemessaging which is not found or resolved.
To Reproduce
1 Create new application using android studio with flutter and dart.
2 Create an application in firebase console and configure your app in android studio following the instrucctions.
3 Add Firebase Messaging 6.0.16 in pubspec.yaml file from https://pub.dev/packages/firebase_messaging#android-integration
4 Follow the instructions to the point 4 and continue with "Optionally handle background messages" apart next.
5 This apart have 6 points. In point 2, when I add java class named Application.java I found the errors described (see picture). At this point 2, android studio dont resolve "import io.flutter.plugins.firebasemessaging....". If I complete the steps the errors persists and It's impposible continue with the app.
Expected behavior
I expected to correctly configure the plugin but I cant.
Additional context
In Application.java in line "import io.flutter.plugins.firebasemessaging...." Android Studio show the error: "cannot resolve simbol firebasemessaging".
In Application.java, in line " FlutterFirebaseMessagingService.setPluginRegistrant(this);" Android Studio show the error: "cannot resolve simbol FlutterFirebaseMessagingService"
And in line "GeneratedPluginRegistrant.registerWith(registry);" (Application.java) Android Studio show another error.
Flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.2, on Microsoft Windows [Versión 10.0.18363.836], locale es-ES)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[√] Android Studio (version 3.6)
[√] VS Code (version 1.45.1)
[√] Connected device (1 available)
• No issues found!
Picture show errors when add Application.java
build.gradle android level
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.2'
}
}
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
}
Build.gradle on app level
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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
dependencies {
// add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.google.firebase:firebase-messaging:20.2.0'
// add SDKs for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
}
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.canovasconsulting.serpol"
minSdkVersion 28
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
Others
I change data in AndroidManifest.xml acording with instruccions:
....
Is gradle problem? Or plugin problem? I need help with this. Thanks
Activity
TahaTesser commentedon Jun 3, 2020
Hi @tronantonio
Please make sure you've this in your
AndroidManifest.xml
and don't forget o Application.java in your manifest and uninstall previous version and run againCan you please provide your
flutter doctor -v
, yourflutter run --verbose
and a minimal complete reproducible code sample.Thank you
tronantonio commentedon Jun 3, 2020
Hi, I really have these lines in my android manifest xml file.
The problem is that compile procces stops when arrived to Application.java file because it cannot resolve some dependencies (see the picture up)
my Main.dart:
Run -verbose
TahaTesser commentedon Jun 8, 2020
Hi @tronantonio
Please create a new project with kotlin support and add this to your
mainactivity
heidji commentedon Jul 4, 2020
@TahaTesser
could you please add the Kotlin variant to the docs? Flutter creates Kotlin apps afaik by default nowadays and scraping the issues for clues was a bit confusing.
TahaTesser commentedon Jul 6, 2020
@heidji #2311
heidji commentedon Jul 6, 2020
@TahaTesser yes I am aware the info is widely available in bug reports, but that's exactly what i was criticizing
google-oss-bot commentedon Jul 30, 2020
Hey @tronantonio. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
google-oss-bot commentedon Aug 10, 2020
Since there haven't been any recent updates here, I am going to close this issue.
@tronantonio if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.