firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.64k stars 3.96k forks source link

🐛 [firebase_analytics] Building failed when adding to flutter Add2App #6524

Closed anujsaxenadev closed 1 year ago

anujsaxenadev commented 3 years ago

Bug report

Describe the bug I have implemented flutter code as a module [Add2App] to my native apps. I am just importing the firebase analytics to my project. When i am not able to build aar file.

Packages Used -

firebase_core: ^1.3.0
firebase_crashlytics: ^2.0.6
firebase_analytics: ^8.1.2

Error From the Console

Note: /Users/home/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.3.0/android/src/main/java/io/flutter/plugins/firebase/core/FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/home/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-8.1.2/android/src/main/java/io/flutter/plugins/firebaseanalytics/FirebaseAnalyticsPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/home/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-8.1.2/android/src/main/java/io/flutter/plugins/firebaseanalytics/FirebaseAnalyticsPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':firebase_analytics:uploadArchives'.
> Could not publish configuration 'archives'
   > Could not write to file '/Users/home/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-8.1.2/android/build/poms/pom-default.xml'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s

Gradle task assembleAarDebug failed with exit code 0.

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.0.1, on macOS 11.3 20E232 darwin-x64, locale en-IN) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS [✓] Chrome - develop for the web [✓] Android Studio (version 4.1) [✓] VS Code (version 1.57.1) [✓] Connected device (1 available) • No issues found! ```

ranjeetscience commented 3 years ago

Facing the same the issue . can someone please help me? I am new to flutter.

markusaksli-nc commented 3 years ago

Hi @anujsaxenadev Could you please provide your pubspec.yaml? Thank you

anujsaxenadev commented 3 years ago
name: flutterTestModule
description: A new flutter module project.

version: 1.0.0+1

environment:
  sdk: '>=2.12.0 <3.0.0'

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.3
  dio: ^4.0.0
  dartz: ^0.10.0-nullsafety.2
  equatable: ^2.0.3
  get_it: ^7.1.3
  provider: ^5.0.0
  url_launcher: ^6.0.6
  intl: ^0.17.0

  html: ^0.15.0
  csslib: ^0.17.0
  css_colors: ^1.1.0
  flutter_layout_grid: ^1.0.0-nullsafety.6
  video_player: ^2.0.0
  chewie: ^1.0.0
  webview_flutter: 2.0.4
  chewie_audio: ^1.2.0
  flutter_svg: ^0.21.0-nullsafety.0
  firebase_core: ^1.3.0
  firebase_crashlytics: ^2.0.6
  firebase_analytics: ^8.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  mockito: ^5.0.10
  http_mock_adapter: ^0.2.1
  build_runner: ^2.0.4

flutter:
  uses-material-design: true
  assets:
    - lib/core/res/images/
  fonts:
    - family: Groteskbold
      fonts:
        - asset: lib/core/res/fonts/groteskbold.ttf
    - family: Groteskreg
      fonts:
        - asset: lib/core/res/fonts/groteskreg.ttf
    - family: Grotesksemibold
      fonts:
        - asset: lib/core/res/fonts/grotesksemibold.ttf

  module:
    androidX: true
    androidPackage: com.example.flutterTestModule
    iosBundleIdentifier: com.example.flutterTestModule
markusaksli-nc commented 3 years ago

Does the issue persist if you add

publish_to: 'none'
anujsaxenadev commented 3 years ago

Tried this still the same result. I even tried this without the quote as it is in the documentation - https://dart.dev/tools/pub/pubspec#publish_to

Does the issue persist if you add

publish_to: 'none'
markusaksli-nc commented 3 years ago

Have you tried running the build command with administrator privileges?

anujsaxenadev commented 3 years ago

Have you tried running the build command with administrator privileges?

Still the same error. Even with administrator privileges.

markusaksli-nc commented 3 years ago

Labeling for further investigation.

Sauvikk commented 3 years ago

I am facing the same issue. I created a fresh flutter module using Android Studio and just added the following dependencies.

  firebase_core: ^1.5.0
  firebase_analytics: ^8.3.0

The issue is present in firebase_messaging: ^10.0.5 as well but the crashlytics plugin firebase_crashlytics: ^2.2.0 seems to be working fine.

Sauvikk commented 3 years ago

I am facing the same issue. I created a fresh flutter module using Android Studio and just added the following dependencies.

  firebase_core: ^1.5.0
  firebase_analytics: ^8.3.0

The issue is present in firebase_messaging: ^10.0.5 as well but the crashlytics plugin firebase_crashlytics: ^2.2.0 seems to be working fine.

This hack seems to resolve the issue https://github.com/FirebaseExtended/flutterfire/issues/3978#issuecomment-825601559

stevanusw28 commented 2 years ago

Is there any update on this issue? It still happened at firebase_analytics: ^9.0.0

chandragupt1201 commented 2 years ago

Even I am facing the same issue. firebase_messaging: ^10.0.9 firebase_analytics: ^8.3.4

Any update on the issue ?

Jan-Stepien commented 2 years ago

Issue is still there.

Anyone successfully generated aar from Flutter module with Firebase (Cloud Firestore especially)?

oleksiy-pavlenko commented 2 years ago

This happens also with firebase_app_check: 0.0.6+13

akshaytaru2007 commented 2 years ago

Hello everyone.

Facing the same issue with the following dependencies

firebase_core: ^1.21.0
firebase_analytics: ^9.3.2

Issue:

* What went wrong:
Execution failed for task ':firebase_analytics:uploadArchives'.
> Could not publish configuration 'archives'
   > Could not write to file '/Users/XXX/Akshay/Personal/Flutter_SDK/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-9.3.2/android/build/poms/pom-default.xml
rckrdstrgrd commented 2 years ago

This issue occurred for me after adding a second firebase dependency, the first being firebase_core. The aar build without any issues when only having firebase_core, when adding firebase_analytics the aar build failed with the same error as above.

I was able to build an aar after applying a workaround detailed here. My guess it that this exception is thrown when two packages have the same dependency. The gradle build script in flutter_tools (flutter/sdk/packages/flutter_tools/gradle/aar_init_script.gradle) needs to be updated to handle this.

russellwheatley commented 1 year ago

This isn't something fixable from FlutterFire, and appears to be an issue with Flutter tooling itself. I would suggest filing an issue on the Flutter repository which illustrates the problem with the script in question. As mentioned, you can just apply the workaround mentioned in the comment above.