1.Add firebase_analytics in pubspec.yaml
2.Use it for tracking user actions
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at io.flutter.plugins.firebaseanalytics.FirebaseAnalyticsPlugin.createBundleFromMap(FirebaseAnalyticsPlugin.java:147)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at io.flutter.plugins.firebaseanalytics.FirebaseAnalyticsPlugin.handleLogEvent(FirebaseAnalyticsPlugin.java:72)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at io.flutter.plugins.firebaseanalytics.FirebaseAnalyticsPlugin.onMethodCall(FirebaseAnalyticsPlugin.java:39)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:152)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at android.app.ActivityThread.main(ActivityThread.java:6541)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
E/MethodChannel#plugins.flutter.io/firebase_analytics( 8545): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
I/flutter ( 8545): PlatformException(error, Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference, null)
flutter doctor -v
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.6 17G65, locale en-IN)
• Flutter version 0.5.1 at /private/var/flutter
• Framework revision c7ea3ca377 (3 months ago), 2018-05-29 21:07:33 +0200
• Engine revision 1ed25ca7b7
• Dart version 2.0.0-dev.58.0.flutter-f981f09760
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/champ/Library/Android/sdk/
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• ANDROID_HOME = /Users/champ/Library/Android/sdk/
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4.1, Build version 9F2000
✗ libimobiledevice and ideviceinstaller are not installed. To install, run:
brew install --HEAD libimobiledevice
brew install ideviceinstaller
✗ ios-deploy not installed. To install:
brew install ios-deploy
✗ CocoaPods not installed.
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
For more info, see https://flutter.io/platform-plugins
To install:
brew install cocoapods
pod setup
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 27.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[!] IntelliJ IDEA Ultimate Edition (version 2018.1.3)
• IntelliJ at /Applications/IntelliJ IDEA.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.io/intellij-setup/#installing-the-plugins
[!] VS Code (version 1.25.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected devices (1 available)
• Google Pixel, 8 0, API 26, 1080x1920 • 192.168.56.101:5555 • android-x86 • Android 8.0.0 (API 26)
! Doctor found issues in 3 categories.
```
@techyrajeev
The issue at https://github.com/flutter/flutter/issues/21202 has been closed and moved here. Future collaboration on this issue will be done here.
where's the update !?!?!?
This issue opened on Oct 14, 2019, still open. @@
Since there is no update on this issue, I guess what we can just do is to convert all null values to a blank string before logging the event:
var paramsWithoutNull = params.map((k, v) => new MapEntry(k, v ?? ''));
FirebaseAnalytics().logEvent(
name: name,
parameters: paramsWithoutNull,
);
Most helpful comment
Since there is no update on this issue, I guess what we can just do is to convert all
nullvalues to a blank string before logging the event: