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_messaging] firebase_messaging plugin causing build error in android #188

Closed
Peteritor opened this issue Sep 20, 2019 · 28 comments
Closed
Labels
type: bug Something isn't working

Comments

@Peteritor
Copy link

Whenever I apply the firebase_messaging plugin, The compiler throws deprecated error on building for android. I tried to change the gradle version, it works in debug mode but not in release. Kindly help regarding this, Its very crucial for me. Thank you.

@Peteritor Peteritor added the type: bug Something isn't working label Sep 20, 2019
@DagobertDokate
Copy link

error: method findAppBundlePath in class FlutterMain cannot be applied to given types;
String appBundlePath = FlutterMain.findAppBundlePath();
^
required: Context
found: no arguments
reason: actual and formal argument lists differ in length
1 error
Finished with error: Gradle task assembleDebug failed with exit code 1

same error?

@satyen893
Copy link

what is your flutter version? Upgrading to Flutter (Channel stable, v1.9.1+hotfix.2) fixed the same. FlutterMain.findAppBundlePath(Context applicationContext); is marked as deprecated in the update.

@DagobertDokate
Copy link

But what if I don't want to change the Flutter version at all? We are on the verge of completing a project. I am using the version ^1.7.8+hotfix.4.
Until yesterday evening everything worked fine.

@yendangn
Copy link

The same issue

@satyen893
Copy link

@DagobertDokate by any means did you run flutter pub upgrade? that might have downloaded the latest plugin (5.1.6). For now you can manually update FlutterMain.findAppBundlePath() to send context.getApplicationContext() / context in the FlutterFirebaseMessagingService.java file and see if it helps. (Is not recommended but worth trying)

@DagobertDokate
Copy link

@satyen893 Not that I'm aware of. Flutter --version also says version 1.7. The only thing I did was flutter pub cache repair.

@ashutoshkmr
Copy link
Contributor

@DagobertDokate you can change you dependency to firebase_messaging: ">=5.0.2 <5.1.5"
Works with v1.7

@DagobertDokate
Copy link

I don't see the problem directly:
I have the following pubspec:
There I refer to 5.1.5

name: push_messaging_client

description: A new Flutter package.
version: 1.1.0
author:
homepage:

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^0.4.0+9
  firebase_messaging: ^5.1.5
  http: ^0.12.0+2
  shared_preferences: ^0.5.3+4

  cockpit_base:
    git:
      url: git@git..../appgalaxy/cockpit-base.git
      ref: develop
  flutter_notification_channel:
    git:
      url: git@git.../appgalaxy/flutter-notification-channel.git
      ref: master

dev_dependencies:
  flutter_test:
    sdk: flutter
  mockito: ^4.1.0

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

# The following section is specific to Flutter.
flutter:

  uses-material-design: true

But the dependency tree says 5.1.6. Why? oO

Dart SDK 2.4.0
Flutter SDK 1.7.8+hotfix.4
push_messaging_client 1.1.0
|-- cockpit_base 1.0.1
| |-- flutter...
| |-- http...
| |-- intl 0.15.8
| | '-- path...
| |-- rxdart 0.22.2
| '-- tracking_client 0.0.1
| |-- firebase_analytics 4.0.2
| | |-- flutter...
| | '-- meta...
| |-- firebase_core...
| |-- firebase_crashlytics 0.1.0+3
| | |-- flutter...
| | '-- stack_trace...
| |-- firebase_performance 0.3.0+5
| | '-- flutter...
| |-- flutter...
| |-- http...
| '-- sentry 2.2.0
| |-- http...
| |-- meta...
| |-- stack_trace...
| '-- usage 3.4.1
| '-- path...
|-- firebase_core 0.4.0+9
| |-- flutter...
| '-- meta...
|-- firebase_messaging 5.1.6
| |-- flutter...
| |-- meta...
| '-- platform 2.2.1
|-- flutter 0.0.0
| |-- collection 1.14.11
| |-- meta 1.1.6
| |-- sky_engine 0.0.99
| |-- typed_data 1.1.6
| '-- vector_math 2.0.8
|-- flutter_notification_channel 0.0.1
| '-- flutter...
|-- flutter_test 0.0.0
| |-- async...
| |-- boolean_selector 1.0.4
| | |-- source_span...
| | '-- string_scanner...
| |-- charcode 1.1.2
| |-- collection...
| |-- flutter...
| |-- matcher 0.12.5
| | '-- stack_trace...
| |-- meta...
| |-- path...
| |-- pedantic...
| |-- quiver 2.0.3
| | |-- matcher...
| | '-- meta...
| |-- source_span 1.5.5
| | |-- charcode...
| | |-- path...
| | '-- term_glyph...
| |-- stack_trace 1.9.3
| | '-- path...
| |-- stream_channel 2.0.0
| | '-- async...
| |-- string_scanner 1.0.4
| | |-- charcode...
| | |-- meta...
| | '-- source_span...
| |-- term_glyph 1.1.0
| |-- test_api 0.2.5
| | |-- async...
| | |-- boolean_selector...
| | |-- collection...
| | |-- matcher...
| | |-- meta...
| | |-- path...
| | |-- pedantic...
| | |-- source_span...
| | |-- stack_trace...
| | |-- stream_channel...
| | |-- string_scanner...
| | '-- term_glyph...
| |-- typed_data...
| '-- vector_math...
|-- http 0.12.0+2
| |-- async 2.2.0
| | '-- collection...
| |-- http_parser 3.1.3
| | |-- charcode...
| | |-- collection...
| | |-- source_span...
| | |-- string_scanner...
| | '-- typed_data...
| |-- path 1.6.2
| '-- pedantic 1.7.0
|-- mockito 4.1.1
| |-- collection...
| |-- matcher...
| |-- meta...
| '-- test_api...
'-- shared_preferences 0.5.3+4
|-- flutter...
'-- meta...

@satyen893
Copy link

@DagobertDokate comment out firebase_messaging: ^5.1.5 run flutter pub get, then add firebase_messaging: 5.1.4 and run flutter pub get. This should get you the correct version

@DagobertDokate
Copy link

DagobertDokate commented Sep 20, 2019

@DagobertDokate comment out firebase_messaging: ^5.1.5 run flutter pub get, then add firebase_messaging: 5.1.4 and run flutter pub get. This should get you the correct version

Does not solve the problem.

Deleting the .pub-cache directory also does not improve the situation. I am open for further suggestions.^^

How can I check if pub sends me the right packet? What is the link about the pub that loads packages?

@ashutoshkmr
Copy link
Contributor

did you remove the caret sign before the version number ?

@DagobertDokate
Copy link

Now I'm really confused. The instructions for Flutter always say very clearly: 'firebase_messaging: ^5.1.6'.
But if I omit '^', it uses the right version.
Should I now remove this from all dependencies? Is this a Flutter/Pub error or do I just not understand the instructions?

@Peteritor
Copy link
Author

I have the latest flutter version-
Flutter 1.9.1+hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2d2a1ffec9 (13 days ago) • 2019-09-06 18:39:49 -0700
Engine • revision b863200c37
Tools • Dart 2.5.0

@Peteritor
Copy link
Author

Only happens when compiling on release mode for android. It works in debug though.
Current configuration -
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.google.gms:google-services:3.2.1'

Build failed LOG------------------------------------>

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':location:verifyReleaseResources'.

java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/sumitsmac/Desktop/LIVE/build/location/intermediates/res/merged/release/values/values.xml:276: error: resource android:attr/fontVariationSettings not found.
/Users/sumitsmac/Desktop/LIVE/build/location/intermediates/res/merged/release/values/values.xml:277: error: resource android:attr/ttcIndex not found.
error: failed linking references.

  • 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 1m 54s
Finished with error: Gradle task assembleRelease failed with exit code 1

Kindly Help

@ashutoshkmr
Copy link
Contributor

Now I'm really confused. The instructions for Flutter always say very clearly: 'firebase_messaging: ^5.1.6'.
But if I omit '^', it uses the right version.
Should I now remove this from all dependencies? Is this a Flutter/Pub error or do I just not understand the instructions?

No you don't need to remove it from all your dependencies. It is just in this case that you need 5.1.5 twhich is compatible with flutter v1.7.
5.1.6 needs flutter v1.9

@DagobertDokate
Copy link

Yes, but the install guid cleary said 'firebase_messageing: ^5.15'. In every dep is '^'. What i should remove it in this case? I don't understand oO

@Peteritor
Copy link
Author

error: method findAppBundlePath in class FlutterMain cannot be applied to given types;
String appBundlePath = FlutterMain.findAppBundlePath();
^
required: Context
found: no arguments
reason: actual and formal argument lists differ in length
1 error
Finished with error: Gradle task assembleDebug failed with exit code 1

same error?

no, Not the same

@Peteritor
Copy link
Author

I have upgraded to firebase_messaging : ^5.1.6 and the error has changed -
Note: /Users/sumitsmac/Documents/Important_flutter/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+3/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/sumitsmac/Documents/Important_flutter/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+3/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.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 ':location:verifyReleaseResources'.

java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/sumitsmac/Desktop/LIVE/build/location/intermediates/res/merged/release/values/values.xml:276: error: resource android:attr/fontVariationSettings not found.
/Users/sumitsmac/Desktop/LIVE/build/location/intermediates/res/merged/release/values/values.xml:277: error: resource android:attr/ttcIndex not found.
error: failed linking references.

  • 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 2m 3s
Finished with error: Gradle task assembleRelease failed with exit code 1

@satyen893
Copy link

@DagobertDokate for now to make your application up and running remove '^' from the firebase_messaging dependency, for more information on this please read What is the caret sign (^) before the dependency version number in Flutter's pubspec.yaml?

@ashutoshkmr
Copy link
Contributor

firebase/cloudfirestore/

this issue is with cloudfirestore plugin

@seo0191
Copy link

seo0191 commented Sep 21, 2019

bad 5.1.6 version....

@Peteritor
Copy link
Author

I get this error in ios now o pushing notification -
nw_connection_receive_internal_block_invoke [C4] Receive reply failed with error "Operation canceled"

@Peteritor
Copy link
Author

Kindly help !

@Raviteja11122
Copy link

same here. Did anyone resolved this issue??

@mfragab
Copy link

mfragab commented Sep 25, 2019

forcing the package version "firebase_messaging: 5.1.5" (remove ^) has solved the issue for me.
i think package v5.1.6 is only compatible with the new flutter v1.9.

@iapicca
Copy link

iapicca commented Oct 23, 2019

Hi @Peteritor
I see there's an open issue addressing the case you described.
Please follow up on that issue,
I'm closing the current one as duplicate.
If you disagree please write in the comments
and I will reopen it.
Thank you

@iapicca iapicca closed this as completed Oct 23, 2019
@iapicca iapicca changed the title [<FIREBASE_MESSAGING>] <firebase_messaging plugin causing build error in android> [firebase_messaging] firebase_messaging plugin causing build error in android Oct 23, 2019
@MohitChachra
Copy link

@DagobertDokate by any means did you run flutter pub upgrade? that might have downloaded the latest plugin (5.1.6). For now you can manually update FlutterMain.findAppBundlePath() to send context.getApplicationContext() / context in the FlutterFirebaseMessagingService.java file and see if it helps. (Is not recommended but worth trying)

we have to add context.getApplicationContext().toString to work properly

@shakthi-cheeniabs
Copy link

shakthi-cheeniabs commented Apr 1, 2020

Old version supports
"FlutterMain.findAppBundlePath()"
New upgraded versions supports
"FlutterMain.findAppBundlePath(context)"

This will solve this issue due to upgrade but you might get other issues due to upgrade.

@firebase firebase locked and limited conversation to collaborators Aug 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests