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.51k stars 3.92k forks source link

[firebase_analytics]: Firebase Analytics 10.10.5 and 10.10.4 version cannot build Android #12770

Closed DevHHM closed 1 month ago

DevHHM commented 1 month ago

Is there an existing issue for this?

Which plugins are affected?

Analytics

Which platforms are affected?

Android

Description

hello, i need help. I'm applying firebase analystic for the first time and I'm getting errors when I build android on flutter. IOS builds fine, but only Android has the problem. I didn't do anything extra, I just looked at the documentation for firebase_analystics and followed it.

Reproducing the issue

firebase_analytics add flutter pub remove firebase_analytics

pubspec.yaml (skip app id)

version: 1.0.9+15

environment:
  sdk: '>=3.1.5 <4.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  bloc: ^8.1.2
  flutter_bloc: ^8.1.3
  go_router: ^14.1.0
  flutter_svg: ^2.0.9
  equatable: ^2.0.5
  hydrated_bloc: ^9.1.2
  path_provider: ^2.1.1
  fluttertoast: ^8.2.4
  kakao_flutter_sdk: ^1.7.0
  flutter_launcher_icons: ^0.13.1
  permission_handler: ^11.0.1
  http: ^1.1.0
  json_serializable: ^6.7.1
  json_annotation: ^4.8.1
  badges: ^3.1.2
  intl: ^0.19.0
  korea_regexp: ^1.2.1
  flutter_secure_storage: ^4.2.1
  flutter_naver_login: ^1.8.0
  sign_in_with_apple: ^6.1.0
  logger: ^2.2.0
  firebase_core: ^2.31.0
  firebase_messaging: ^14.9.2
  flutter_local_notifications: ^17.1.2
  app_links: ^6.0.1
  firebase_analytics: ^10.10.4

dev_dependencies:
  build_runner: ^2.4.7
  flutter_test:
    sdk: flutter

flutter_launcher_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/icons/app_icon.png"
  min_sdk_android: 21 # android min sdk min:16, default 21
  web:
    generate: true
    image_path: "assets/icons/app_icon.png"
#    background_color: "#hexcode"
#    theme_color: "#hexcode"
  windows:
    generate: true
    image_path: "assets/icons/app_icon.png"
    icon_size: 48 # min:48, max:256, default: 48
  macos:
    generate: true
    image_path: "assets/icons/app_icon.png"

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
     - assets/images/
     - assets/icons/
     - assets/svg/

Firebase Core version

2.31.0

Flutter Version

3.19.6

Relevant Log Output

/Users/username/Developments/flutter/bin/flutter --no-color build apk

Running Gradle task 'assembleRelease'...                        
Note: /Users/username/.pub-cache/hosted/pub.dev/flutter_secure_storage-4.2.1/android/src/main/java/com/it_nomads/fluttersecurestorage/FlutterSecureStoragePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Font asset "CupertinoIcons.ttf" was tree-shaken, reducing it from 257628 to 848 bytes (99.7% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
Font asset "MaterialIcons-Regular.otf" was tree-shaken, reducing it from 1645184 to 2260 bytes (99.9% reduction). Tree-shaking can be disabled by providing the --no-tree-shake-icons flag when building your app.
ERROR:D8: com.android.tools.r8.kotlin.H

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeExtDexRelease'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
   > Failed to transform play-services-measurement-api-21.6.1.aar (com.google.android.gms:play-services-measurement-api:21.6.1) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=false, dexing-min-sdk=21, org.gradle.status=release, org.gradle.usage=java-runtime}.
      > Execution failed for DexingWithClasspathTransform: /Users/username/.gradle/caches/transforms-3/88a075a3126a401f5a1265280fdb064b/transformed/jetified-play-services-measurement-api-21.6.1-runtime.jar.
         > Error while dexing.

* 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 36s
Running Gradle task 'assembleRelease'...                           36.9s

β”Œβ”€ Flutter Fix ──────────────────────────────────────────────────────────────┐
β”‚ [!] The shrinker may have failed to optimize the Java bytecode.            β”‚
β”‚ To disable the shrinker, pass the `--no-shrink` flag to this command.      β”‚
β”‚ To learn more, see: https://developer.android.com/studio/build/shrink-code β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1

Flutter dependencies

Expand Flutter dependencies snippet
```yaml Replace this line with the contents of your `flutter pub deps -- --style=compact`. ```

Additional context and comments

I've also reached out to the firebase slack for help. However, I did a little research on past cases like this and found that 'This is a library bug', so I'm leaving it as an issue.

TarekkMA commented 1 month ago

Hey @DevHHM, thank you for reporting this issue. I've tested version 10.10.5 of analytics, and it runs without issues. Could you please try to provide a minimal but complete reproducible example where this issue occurs?

AkashBonito commented 1 month ago

Same Issue occuring to me, even in firebase_analytics: 10.10.3 version.

DevHHM commented 1 month ago

@TarekkMA Unfortunately, we don't have any examples to provide.

Because all I did was add Firebase_analytics, read the official documentation, set up the file, and initialized it on app launch.

For now, the problem is solved. On Stackoverflow, users with similar symptoms to mine said that raising Minsdkversion to 24 should fix it, so I followed that. I did so, and it built without issue.

However, the official documentation says to keep it at 21. Can you please confirm that this is indeed the case?

@AkashBonito If that doesn't work, try raising minsdkversion to 24 like I did.

AkashBonito commented 1 month ago

@TarekkMA Worked for me after changing minsdkversion to 24. Thanks a ton!!

TarekkMA commented 1 month ago

@DevHHM, glad to hear that you have found a fix for this issue. Can you please send a link to the documentation that mentions minSdk 21 so we can update it?

russellwheatley commented 1 month ago

@TarekkMA - I just built (debug + release) the analytics example app with minSdk 21, and it worked. This issue can be closed out as the user has a solution πŸ‘Œ

DevHHM commented 1 month ago

@TarekkMA https://firebase.google.com/support/release-notes/android If you look here, it says that MINSDKVERSION must be 21 or higher. Of course, this is the release notes for Android, but the article says that you should use version 21 or higher. And the flutter documentation doesn't specify it at all.