How to fix “Exception thrown while unbinding, java.lang.IllegalArgumentException: Service not registered: lp@9f7d4ca” exception in Flutter? [duplicate]

允我心安 提交于 2020-12-19 06:58:47

问题


My debug console show me this:

W/ConnectionTracker(17934): Exception thrown while unbinding
W/ConnectionTracker(17934): java.lang.IllegalArgumentException: Service not registered: lp@9f7d4ca
W/ConnectionTracker(17934):     at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1557)
W/ConnectionTracker(17934):     at android.app.ContextImpl.unbindService(ContextImpl.java:1692)
W/ConnectionTracker(17934):     at android.content.ContextWrapper.unbindService(ContextWrapper.java:717)
W/ConnectionTracker(17934):     at ci.f(:com.google.android.gms.dynamite_measurementdynamite@204215067@20.42.15 (100408-0):1)
W/ConnectionTracker(17934):     at ci.d(:com.google.android.gms.dynamite_measurementdynamite@204215067@20.42.15 (100408-0):2)
W/ConnectionTracker(17934):     at lq.D(:com.google.android.gms.dynamite_measurementdynamite@204215067@20.42.15 (100408-0):10)
W/ConnectionTracker(17934):     at lc.a(:com.google.android.gms.dynamite_measurementdynamite@204215067@20.42.15 (100408-0):2)

I dont know how do i do it.


回答1:


Add the following to your android\app\build.gradle

implementation 'com.google.android.gms:play-services-basement:17.5.0'
implementation 'com.google.firebase:firebase-analytics:18.0.0'



回答2:


EDIT 16th Dec: The fix for this warning will be rolled out in February. Not sure how/why this thread was marked as closed and fixed because there were multiple cases of workarounds that worked more or less.

The real fix will be to try some of the suggestion and if they fail, just wait.

EDIT 13th Dec: From this Git discussion we have a confirmation that this error doesn't cause any other issues, nor crashes.

The old machine that wasn't throwing errors started doing so after an update.

We just have to wait for the update that will make these warnings go away.

EDIT 8th Dec: Nor Java nor adding the SHAs to my Firebase console helped with anything!

EDIT 4th Dec: Looks like on the machine with issues, I didn't have Java installed. All looks well after multiple builds and wipes. I'll keep an eye out!

Visit Oracle's site to download it! Thanks to Talha's comment about SHA (keytool requires Java)!

EDIT 3rd Dec: I did another Firebase setup and as Timo Bähr pointed out, the docs for Firebase setup were updated. As you can see, firebase-bom was added, but also the option to pick Java or Kotlin.

Double checked my project and:

  1. changed all dependencies to Kotlin (-ktx ending)
  2. wiped all the devices data
  3. removed old unused emulators
  4. cold booted the device (both from Android Studio Virtual device manager)

Now the errors are gone (for now?)!

// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:26.1.0')

// When using the BoM, you don't specify versions in Firebase library dependencies

// Declare the dependency for the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics-ktx'

// Declare the dependencies for any other desired Firebase products
// For example, declare the dependencies for Firebase Authentication and Cloud Firestore
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'

EDIT 26th Nov: Exceptions are back even with previous fix from King.

EDIT 23rd Nov: The errors started appearing again after 1-2 days. Please check King Alawaka's answer which may hold the solution which is the same as this Github reply. Positive feedback is coming from it. :)

Initial response: After updating the Firebase dependencies I got rid of these errors. Here are the versions I'm currently using:

firebase_core: ^0.5.2
firebase_database: ^4.3.0
firebase_analytics: ^6.2.0
firebase_messaging: ^7.0.3
firebase_crashlytics: ^0.2.3

This may not help because I saw this git issue where the reported versions are similar to the ones I use.

Other options that failed:

  • implementation 'com.google.android.gms:play-services-basement:17.5.0' to android\app\build.gradle
  • downgrade certain packages only to versions ~1 month old
  • disabling analytics and crashlytics (removed the packages too)
  • switching emulated device
  • whipping all data on those device/s



回答3:


Latest Firebase documentation saying:

// Add this line
apply plugin: 'com.google.gms.google-services'

dependencies {
    ...
    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:26.1.0')

    // Add the dependency for the Firebase SDK for Google Analytics
    // When using the BoM, don't specify versions in Firebase dependencies
    implementation 'com.google.firebase:firebase-analytics-ktx'

    // Add the dependencies for any other desired Firebase products
    // https://firebase.google.com/docs/android/setup#available-libraries
}

After adding firebase-analytics-ktx the error disappeared.



来源:https://stackoverflow.com/questions/64820697/how-to-fix-exception-thrown-while-unbinding-java-lang-illegalargumentexception