Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [firebase_analytics] Missing google_app_id. FIrebase Analytics disabled. #12078

Closed
JCKodel opened this issue Dec 27, 2023 · 10 comments
Closed
Labels
resolution: solution-provided A solution has been provided in the issue. type: bug Something isn't working

Comments

@JCKodel
Copy link

JCKodel commented Dec 27, 2023

Bug report

Describe the bug
Firebase won't work by default in Flutter.

I need to manually add those lines on my android/build.grade:

buildscript {
  dependencies {
    classpath 'com.google.gms:google-services:4.3.15'

and then apply it on android/app/build.gradle:

plugins {
  id "com.google.gms.google-services"

Without those additions, the following error is displayed on the console:

E/FA: Missing google_app_id. Firebase Analytics disabled. See https://useless-link

But 4.3.15 is not the latest version. Documentation says it is 4.4.0. Problem is: with 4.4.0, the same error appears and analytics won't work.

In other words:

  1. Without any intervation, firebase_analytics doesn't work
  2. Using com.google.gms:google-services:4.3.15 does work
  3. Using com.google.gms:google-services:4.4.0 doesn't work

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a project with firebase_analytics and follow the documentation
  2. Log some event

Expected behavior

To work, without any kind of warning, especially about deprecated APIs!!!!

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, 3.16.5, on Microsoft Windows [Version 10.0.22631.2861], locale pt-BR)
    ! Warning: `flutter` on your path resolves to C:\Users\jckod\fvm\versions\3.16.5\bin\flutter, which is not inside your current Flutter SDK checkout at C:\Users\jckod\fvm\default. Consider adding
      C:\Users\jckod\fvm\default\bin to the front of your path.
    ! Warning: `dart` on your path resolves to C:\Users\jckod\fvm\versions\3.16.5\bin\dart, which is not inside your current Flutter SDK checkout at C:\Users\jckod\fvm\default. Consider adding
      C:\Users\jckod\fvm\default\bin to the front of your path.
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.3)
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.85.1)
[✓] Connected device (4 available)
[✓] Network resources

! Doctor found issues in 1 category.

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 3.2.3
Flutter SDK 3.16.5
maismulher 0.0.2+2

dependencies:
- cupertino_icons 1.0.6
- dart_mappable 4.2.0 [collection meta type_plus]
- firebase_analytics 10.7.4 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_auth 4.15.3 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 2.24.2 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 3.4.8 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math web]
- get_it 7.6.4 [async collection]
- google_sign_in 6.2.1 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web]
- injectable 2.3.2 [get_it]
- ksuid 1.0.0 [convert]
- local_auth 2.1.7 [flutter local_auth_android local_auth_ios local_auth_platform_interface local_auth_windows]
- lottie 2.7.0 [archive flutter path vector_math]
- markdown_viewer 0.6.2 [flutter dart_markdown]
- material_symbols_icons 4.2713.0 [flutter]
- path_provider 2.1.1 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- sign_in_with_apple 5.0.0 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web]
- slide_indexed_stack 0.0.1 [flutter]
- sqflite_common 2.5.0+2 [synchronized path meta]
- sqflite_common_ffi 2.3.1 [sqlite3 sqflite_common synchronized path meta]
- sql_crdt 2.1.5+1 [crdt source_span sqlparser]
- sqlite3_flutter_libs 0.5.18 [flutter]
- sqlite_viewer 1.0.5 [flutter json_table path sqflite]
- url_launcher 6.2.2 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- watch_it 1.1.0 [get_it flutter functional_listener]

dev dependencies:
- build_runner 2.4.7 [analyzer args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml]
- dart_mappable_builder 4.2.0 [analyzer ansicolor build collection dart_mappable dart_style glob path source_gen]
- flutter_launcher_icons 0.13.1 [args checked_yaml cli_util image json_annotation path yaml]
- flutter_lints 2.0.3 [lints]
- flutter_native_splash 2.3.8 [args flutter flutter_web_plugins js html image meta path universal_io xml yaml ansicolor]
- injectable_generator 2.4.1 [build source_gen path glob analyzer code_builder dart_style injectable collection recase meta]

transitive dependencies:
- _fe_analyzer_shared 64.0.0 [meta]
- _flutterfire_internals 1.3.16 [collection firebase_core firebase_core_platform_interface flutter meta]
- analyzer 6.2.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml]
- ansicolor 2.0.2
- archive 3.4.9 [crypto path pointycastle]
- args 2.4.2
- async 2.11.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- build 2.4.1 [analyzer async convert crypto glob logging meta package_config path]
- build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml]
- build_daemon 4.0.1 [built_collection built_value crypto http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel]
- build_resolvers 2.4.2 [analyzer async build collection convert crypto graphs logging package_config path pool pub_semver stream_transform yaml]
- build_runner_core 7.2.11 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta package_config path pool timing watcher yaml]
- built_collection 5.1.1
- built_value 8.8.1 [built_collection collection fixnum meta]
- characters 1.3.0
- charcode 1.3.1
- checked_yaml 2.0.3 [json_annotation source_span yaml]
- cli_util 0.4.1 [meta path]
- clock 1.1.1
- code_builder 4.9.0 [built_collection built_value collection matcher meta]
- collection 1.18.0
- convert 3.1.1 [typed_data]
- crdt 5.1.2 [meta uuid]
- crypto 3.0.3 [typed_data]
- csslib 1.0.0 [source_span]
- dart_markdown 3.1.7 [args source_span]
- dart_style 2.3.4 [analyzer args collection path pub_semver source_span]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.0
- file 7.0.0 [meta path]
- firebase_analytics_platform_interface 3.8.4 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.5.5+11 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js]
- firebase_auth_platform_interface 7.0.9 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.8.12 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta]
- firebase_core_platform_interface 5.0.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.10.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_crashlytics_platform_interface 3.6.16 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- fixnum 1.1.0
- flutter_plugin_android_lifecycle 2.0.17 [flutter]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math async boolean_selector characters collection material_color_utilities meta source_span stream_channel string_scanner term_glyph web]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web]
- frontend_server_client 3.2.0 [async path]
- functional_listener 2.3.1 [flutter]
- glob 2.1.2 [async collection file path string_scanner]
- google_identity_services_web 0.3.0+2 [meta web]
- google_sign_in_android 6.1.20 [flutter google_sign_in_platform_interface]
- google_sign_in_ios 5.7.1 [flutter google_sign_in_platform_interface]
- google_sign_in_platform_interface 2.4.3 [flutter plugin_platform_interface]
- google_sign_in_web 0.12.3+1 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http web]
- graphs 2.3.1 [collection]
- html 0.15.4 [csslib source_span]
- http 1.1.2 [async http_parser meta web]
- http_multi_server 3.2.1 [async]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- image 4.1.3 [archive meta xml]
- intl 0.18.1 [clock meta path]
- io 1.0.4 [meta path string_scanner]
- js 0.6.7 [meta]
- json_annotation 4.8.1 [meta]
- json_table 2.0.1 [flutter]
- lints 2.1.1
- local_auth_android 1.0.36 [flutter flutter_plugin_android_lifecycle intl local_auth_platform_interface]
- local_auth_ios 1.1.5 [flutter intl local_auth_platform_interface]
- local_auth_platform_interface 1.0.8 [flutter plugin_platform_interface]
- local_auth_windows 1.0.10 [flutter local_auth_platform_interface]
- logging 1.2.0
- matcher 0.12.16 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.5.0 [collection]
- meta 1.10.0
- mime 1.0.4
- package_config 2.1.0 [path]
- path 1.8.3
- path_provider_android 2.2.1 [flutter path_provider_platform_interface]
- path_provider_foundation 2.3.1 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.1 [flutter platform plugin_platform_interface]
- path_provider_windows 2.2.1 [ffi flutter path path_provider_platform_interface win32]
- petitparser 6.0.2 [meta]
- platform 3.1.3
- plugin_platform_interface 2.1.7 [meta]
- pointycastle 3.7.3 [collection convert js]
- pool 1.5.1 [async stack_trace]
- pub_semver 2.1.4 [collection meta]
- pubspec_parse 1.2.3 [checked_yaml collection json_annotation pub_semver yaml]
- recase 4.1.0
- shelf 1.4.1 [async collection http_parser path stack_trace stream_channel]
- shelf_web_socket 1.0.4 [shelf stream_channel web_socket_channel]
- sign_in_with_apple_platform_interface 1.0.0 [flutter plugin_platform_interface meta]
- sign_in_with_apple_web 1.0.1 [flutter flutter_web_plugins sign_in_with_apple_platform_interface js]
- sky_engine 0.0.99
- source_gen 1.5.0 [analyzer async build dart_style glob path source_span yaml]
- source_span 1.10.0 [collection path term_glyph]
- sprintf 7.0.0
- sqflite 2.3.0 [flutter sqflite_common path]
- sqlite3 2.3.0 [collection ffi js meta path]
- sqlparser 0.32.1 [meta collection source_span charcode]
- stack_trace 1.11.1 [path]
- stream_channel 2.1.2 [async]
- stream_transform 2.1.0
- string_scanner 1.2.0 [source_span]
- synchronized 3.1.0+1
- term_glyph 1.2.1
- test_api 0.6.1 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- timing 1.0.1 [json_annotation]
- type_plus 2.1.0
- typed_data 1.3.2 [collection]
- universal_io 2.2.2 [collection meta typed_data]
- url_launcher_android 6.2.0 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.2.1 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.1.1 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.1.0 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.2.0 [flutter plugin_platform_interface]
- url_launcher_web 2.2.2 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.1 [flutter url_launcher_platform_interface]
- uuid 4.2.2 [crypto sprintf meta]
- vector_math 2.1.4
- watcher 1.1.0 [async path]
- web 0.3.0
- web_socket_channel 2.4.0 [async crypto stream_channel]
- win32 5.1.1 [ffi]
- xdg_directories 1.0.3 [meta path]
- xml 6.5.0 [collection meta petitparser]
- yaml 3.1.2 [collection source_span string_scanner]

@JCKodel JCKodel added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Dec 27, 2023
@orangeyong
Copy link

same here, double confirmed on clean project and existing project.

@danagbemava-nc danagbemava-nc added the triage Issue is currently being triaged. label Dec 29, 2023
@danagbemava-nc
Copy link

Hi @JCKodel, did you do the setup with the flutterfire_cli. If so, can you try invertase/flutterfire_cli#210 (comment) to see if it is setup properly?

@danagbemava-nc danagbemava-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Dec 29, 2023
@JCKodel
Copy link
Author

JCKodel commented Dec 29, 2023

@danagbemava-nc

Attempt 1:

  • I've removed any build.gradle additions (since the documentation says nothing about add something there)
  • I've updated flutterfire_cli to 0.3.0.dev-18
  • I've run flutterfire configure again
  • I've run flutter clean && flutter pub get

Same error (Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI)

Attempt 2:

  • Same as previous, but I've added latest com.google.gms:google-services (4.4.0) in build.gradle as dependencies { classpath 'com.google.gms:google-services:4.4.0' }
  • Also added plugins { id "com.google.gms.google-services" }
  • flutter clean && flutter pub get

Same error (Missing google_app_id. Firebase Analytics disabled. See https://goo.gl/NAOOOI)

Nothing has changed.

Reverting it to classpath 'com.google.gms:google-services:4.3.15', works as intended.

Also, why one build.gradle uses buildscript but the other uses plugins??? Documentation says plugins is the new way and buildscript is deprecated =\

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Dec 29, 2023
@danagbemava-nc
Copy link

Hi @JCKodel, what google-service version is generated by the cli?
Does it work with that version?

@danagbemava-nc danagbemava-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jan 3, 2024
@JCKodel
Copy link
Author

JCKodel commented Jan 3, 2024

Hi @JCKodel, what google-service version is generated by the cli? Does it work with that version?

And how do I check this?

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jan 3, 2024
@danagbemava-nc
Copy link

The version will be in your build.gradle file surrounded by START: Flutterfire configuration

@danagbemava-nc danagbemava-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jan 4, 2024
@JCKodel
Copy link
Author

JCKodel commented Jan 4, 2024

The version will be in your build.gradle file surrounded by START: Flutterfire configuration

Flutterfire doesn't touch build.gradle.

I've created a new Flutter project, then added on a git repository and commit it.

So, I ran flutter pub add firebase_analytics firebase_core, then flutterfire configure.

These are the changes made by those two commands:

image

Build.gradle (both of it) weren't touched.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jan 4, 2024
@danagbemava-nc
Copy link

That's odd. Can you try using flutterfire_cli 0.3.0-dev.19 to see if it generates the configuration for you? You can install that version by running dart pub global activate flutterfire_cli 0.3.0-dev.19 --overwrite

Using 0.3.0-dev.19 in a new flutter project, my android/app/build.gradle now has

plugins {
    id "com.android.application"
    // START: FlutterFire Configuration
    id 'com.google.gms.google-services'
    // END: FlutterFire Configuration
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

& android/build.gradle has

dependencies {
        // START: FlutterFire Configuration
        classpath 'com.google.gms:google-services:4.3.15'
        // END: FlutterFire Configuration
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }

@danagbemava-nc danagbemava-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jan 5, 2024
@JCKodel
Copy link
Author

JCKodel commented Jan 5, 2024

TL;DR: It works.

> flutter create --description="xxx" --org="xxx" --project-name="xxx" --platforms="android,ios" frontend
OK

> cd frontend
OK

> flutter pub add firebase_analytics firebase_core
+ firebase_analytics 10.8.0
+ firebase_core 2.24.2

> dart pub global activate flutterfire_cli 0.3.0-dev.19 --overwrite
Activated flutterfire_cli 0.3.0-dev.19.

> flutterfire configure  
✔ android
✔ ios
Firebase configuration file lib\firebase_options.dart generated successfully with the following Firebase apps:

> cd android
OK

> type build.bradle
buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        // START: FlutterFire Configuration
        classpath 'com.google.gms:google-services:4.3.15'
        // END: FlutterFire Configuration
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

> cd app
> OK

> type build.gradle
plugins {
    id "com.android.application"
    // START: FlutterFire Configuration
    id 'com.google.gms.google-services'
    // END: FlutterFire Configuration
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "xxx"
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "xxx"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    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 {}

This version of flutterfire adds the 4.3.15 version (which seems to work).

I had to clean my flutter pub cache, otherwise, it would not recognize import 'package:firebase_core/firebase_core.dart';

After that, this code runs without any kind of warning (which I assume it worked)

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  FirebaseAnalytics.instance.logAppOpen();;
  runApp(const MyApp());
}

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jan 5, 2024
@russellwheatley
Copy link
Member

Thanks for letting us know, @JCKodel 🙏. There was a fix in flutterfire_cli 0.3.0-dev.19 for the android build.gradle updates.

@danagbemava-nc danagbemava-nc added resolution: solution-provided A solution has been provided in the issue. and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Jan 8, 2024
@firebase firebase locked and limited conversation to collaborators Feb 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: solution-provided A solution has been provided in the issue. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants