flutterfire
flutterfire copied to clipboard
🐛 [firebase_analytics] FlutterFirebaseAnalyticsPlugin has unchecked cast
Bug report
Describe the bug Build is throwing warnings. compiling with details shows it is an unchecked cast within FlutterFirebaseAnalyticsPlugin.java
/Users/Applications/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-9.1.7/android/src/main/java/io/flutter/plugins/firebase/analytics/FlutterFirebaseAnalyticsPlugin.java:69: warning: [unchecked] unchecked cast
list.add(createBundleFromMap((Map<String, Object>) item));
^
required: Map<String,Object>
found: Object
/Users/Applications/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-9.1.7/android/src/main/java/io/flutter/plugins/firebase/analytics/FlutterFirebaseAnalyticsPlugin.java:82: warning: [unchecked] unchecked cast
bundle.putParcelable(key, createBundleFromMap((Map<String, Object>) value));
^
required: Map<String,Object>
found: Object
Steps to reproduce
Steps to reproduce the behavior:
- Compiled with android studio on mac
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, 2.10.5, on macOS 12.2.1 21D62 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.66.2)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
Flutter dependencies
using: firebase_core: ^1.16.0 firebase_analytics: ^9.1.7 firebase_auth: ^3.3.17 cloud_firestore: ^3.1.14
firebase_crashlytics: ^2.7.2 firebase_messaging: ^11.3.0 firebase_performance: ^0.8.0+11
@bswhite1 I tried using the plugin example with latest version, but didn't get the exception reported. Are there any specific steps to see the log ?
Just pulled the flutterfire firebase_analytics example. Made the following changes
android/app/build.gradle
compileSdkVersion 31
android/build.gradle
classpath 'com.android.tools.build:gradle:7.1.3'
I also added the following:
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked"
}
}
android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
Did a flutter clean, flutter pub get, then build. I see these errors.
I think I'd prefer to do the Map checks in the dart layer before it gets to the android side. We're getting the map from the parameters passed in from the Dart layerlogEvent() and calling Firebase Android SDK own logEvent(). My sense is we should update the log event function in the dart layer to stop any unallowed params from being passed in.
The only map allowed, as far as I can tell, is the one that is allowed in the items array here. According to the documentation, every other property has to be a primitive value (numbers and strings).
So I think I'll improve the Map checks in the dart layer and make a note in the android code to explain why it is unchecked.
I am still getting this issue in version 9.3.5 on flutter sdk 3.3.2
Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_analytics-9.3.5\android\src\main\java\io\flutter\plugins\firebase\analytics\FlutterFirebaseAnalyticsPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Any solutions ?