Describe the bug
Following the steps to install analytics, everything seems to be connected on the Firebase console on initial setup, but when no screen views are coming through and when debugging the app I see this error on the console: W/FA (22526): setCurrentScreen cannot be called with the same class and name
To Reproduce
Steps to reproduce the behavior:
Follow instructions on https://pub.dev/packages/firebase_analytics to install and Track PageRoute Transitions
Expected behavior
Screen views should show up in Firebase Analytics Console
Flutter doctor
Run flutter doctor and paste the output below:
[✓] Flutter (Channel beta, v1.17.0-3.4.pre, on Mac OS X 10.15.4 19E287, locale
en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[!] VS Code (version 1.44.2)
✗ Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (5 available)
I can reproduce this issue
D/ViewRootImpl@283220f[MainActivity](15684): ViewPostIme pointer 1
W/FA (15684): setCurrentScreen cannot be called with the same class and name
D/InputMethodManager(15684): prepareNavigationBarInfo() DecorView@64f1704[MainActivity]
flutter doctor -v
[✓] Flutter (Channel dev, v1.18.0-8.0.pre, on Mac OS X 10.15.4 19E287, locale
en-GB)
• Flutter version 1.18.0-8.0.pre at /Users/taha/Code/flutter_dev
• Framework revision e0c63cd35e (11 days ago), 2020-04-23 22:29:01 -0400
• Engine revision d2ec21221e
• Dart version 2.9.0 (build 2.9.0-3.0.dev b0d35855d8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/taha/Code/sdk
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = /Users/taha/Code/sdk
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.4.1, Build version 11E503a
• CocoaPods version 1.9.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
[✓] VS Code (version 1.44.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.10.1
[✓] Connected device (5 available)
• SM M305F • 32003c30dc19668f • android-arm64 • Android 10 (API
29)
• AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API
28) (emulator)
• macOS • macOS • darwin-x64 • Mac OS X 10.15.4
19E287
• Web Server • web-server • web-javascript • Flutter Tools
• Chrome • chrome • web-javascript • Google Chrome
81.0.4044.129
• No issues found!
I report the same issue. I consider screen tracking as one of the core offerings of Firebase Analytics. Therefore this issue is quite blocking. Is there any update?
Hi, any update on this?
Hey here, I faced same problem recently with analytics. Apparently there is a missing part in a library setup guide.
I found this post which explains the problem itself and provides a valid solution
https://morioh.com/p/a429fd6f5a91
Basically solution here is to specify a RouteSettings for each navigation route you create.
This can be done like:
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => MyPage(),
settings: RouteSettings(name: 'MyPage'), //missing part!
),
);
in my case, I'm using PageRouteBuilder and following a same approach RouteSettings can be specified like:
PageRouteBuilder(
settings: RouteSettings(name: enterPage.runtimeType.toString())
...
build rest of your route here
)
where enterPage.runtimeType.toString() will retrieve your current widget which triggers a navigation.
That's quite a clunky solution. Anything better yet?
...and solution for home:
// home: HomeScreen(),
onGenerateRoute: (RouteSettings settings) {
if (settings.name == '/') {
final homeSettings = RouteSettings(name: '/home');
return Platform.isIOS
? CupertinoPageRoute(
settings: homeSettings,
builder: (_) => HomeScreen())
: MaterialPageRoute(
settings: homeSettings,
builder: (_) => HomeScreen());
}
return null;
},
The Flutter Guide to Firebase Analytics:
@override
void initState() {
super.initState();
analytics.setCurrentScreen(screenName: '/home');
}
The Flutter Guide to Firebase Analytics:
@override void initState() { super.initState(); analytics.setCurrentScreen(screenName: '/home'); }
That works?
The Flutter Guide to Firebase Analytics:
@override void initState() { super.initState(); analytics.setCurrentScreen(screenName: '/home'); }That works?
Well it doesn't for me. I still get the error even though I have the following code on all my named routes.
@override
void initState() {
super.initState();
analytics.setCurrentScreen(screenName: '/name_of_the_route');
}
Hello,
Any news about this?
I have the same issue even if add the RouteSettings parameter.
Thanks!
SOLUTION:
For me, I was trying to navigate to another page when the bottom sheet was open.
So, first use Navigator.pop(context) and then Navigate to another page.
Most helpful comment
Hey here, I faced same problem recently with analytics. Apparently there is a missing part in a library setup guide.
I found this post which explains the problem itself and provides a valid solution
https://morioh.com/p/a429fd6f5a91
Basically solution here is to specify a
RouteSettingsfor each navigation route you create.This can be done like:
in my case, I'm using
PageRouteBuilderand following a same approachRouteSettingscan be specified like:where
enterPage.runtimeType.toString()will retrieve your current widget which triggers a navigation.