What could possibly wrong if I leave this error? java.lang.IllegalArgumentException: Service not registered: lu@5d88aef

Viewed 474

I'm trying to make a Flutter app with FCM and Local Notification, totally blind with native android/kotlin development. I'm having problem when setting up firebase_messaging on the app, it was fixed by converting this "solution" to Kotlin and use it in my Flutter app (which use Kotlin anyway).

The app works, it performs well with no problem. But I have new exception thrown on the console stating this:

W/ConnectionTracker(19481): Exception thrown while unbinding
W/ConnectionTracker(19481): java.lang.IllegalArgumentException: Service not registered: lu@5d88aef
W/ConnectionTracker(19481):     at android.app.LoadedApk.forgetServiceDispatcher(Unknown Source:195)
W/ConnectionTracker(19481):     at android.app.ContextImpl.unbindService(Unknown Source:11)
W/ConnectionTracker(19481):     at android.content.ContextWrapper.unbindService(Unknown Source:2)
W/ConnectionTracker(19481):     at ci.f(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):1)
W/ConnectionTracker(19481):     at ci.d(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):2)
W/ConnectionTracker(19481):     at lv.E(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):9)
W/ConnectionTracker(19481):     at lf.a(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):3)
W/ConnectionTracker(19481):     at ef.run(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):3)
W/ConnectionTracker(19481):     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
W/ConnectionTracker(19481):     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
W/ConnectionTracker(19481):     at iy.run(:com.google.android.gms.dynamite_measurementdynamite@204516081@20.45.16 (120400-0):5)

However, the app doesn't crash or freeze. I would like to anticipate the worst schenario and try to fix it but I don't know how since Flutter uses Dart, and there is only 2 Kotlin files on the src directory; Application.kt which I created for the fix, and MainActivity.kt created by the framework.

What could possibly wrong if I ignore that exception and just move on? Will it become a big problem? if so.. How can I fix it?

Also please have a look At those 2 Kotlin file I mentioned before, and my app/gradle file. I really need your help. Thanks in advance!

Application.kt

package com.example.todoops

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
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin

class Application:FlutterApplication(), PluginRegistrantCallback {
  override fun onCreate() {
    super.onCreate()
    FlutterFirebaseMessagingService.setPluginRegistrant(this)
  }
  override fun registerWith(pluginRegistry:PluginRegistry) {
    FirebaseMessagingPlugin.registerWith(pluginRegistry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
  }
}

MainActivity.kt

package com.example.todoops

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}

src/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'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 29

    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 "com.example.todoops"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    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 '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.android.gms:play-services-basement:17.5.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.google.firebase:firebase-messaging:21.0.0'
}

apply plugin: 'com.google.gms.google-services'

3 Answers

After hours googling around, I found the answer from Firebase team on their repo saying that it's not a fatal error. It was annoying to see the exception popping up at random time but fortunately it can be fold/excluded by the IDE.

So.. There is nothing to do but move on and wait until they fixed it (hopefully).

Not sure but try with below steps

Add to build.gradle (../android/app/build.gradle)

dependencies {
    // other imports
    implementation 'com.google.firebase:firebase-analytics:18.0.0'
    implementation 'com.google.android.gms:play-services-basement:17.5.0'
}

Suggestion first try with only

implementation 'com.google.firebase:firebase-analytics:18.0.0'
Related