Solvedflutterfire πŸ› [firebase_remote_config: 0.4.1] Plugin using removed method, causing app to crash

Bug report

Using the newest release from the Firebase Android SDK, the app crashes immediately when RemoteConfig.instance gets called. This error gets displayed before the crash:

E/flutter (18539): [ERROR:flutter/shell/platform/android/platform_view_android_jni_impl.cc(43)] java.lang.NoSuchMethodError: No virtual method isDeveloperModeEnabled()Z in class Lcom/google/firebase/remoteconfig/FirebaseRemoteConfigSettings; or its super classes (declaration of 'com.google.firebase.remoteconfig.FirebaseRemoteConfigSettings' appears in /data/app/my.app-ItOxdJo5ljyanMFjofxlDg==/base.apk)

The cause is that isDeveloperModeEnabled got removed from FirebaseRemoteConfigSettings on this commit. The method was deprecated a while ago, yet it is still used here.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create a new Flutter app.
  2. Install and configure the firebase_remote_config package using the latest Firebase Android SDK (com.google.firebase:firebase-config:20.0.0 or com.google.firebase:firebase-bom:26.0.0)
  3. Put final RemoteConfig remoteConfig = await RemoteConfig.instance; somewhere in the code.
  4. The app now crashes when that code is reached.

Expected behavior

The app should not crash.


Additional context

Dependencies on android/app/build.gradle:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    implementation platform('com.google.firebase:firebase-bom:26.0.0')
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-crashlytics-ktx'
}

apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'

Dependencies on android/build.gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:4.1.0'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'com.google.gms:google-services:4.3.4'
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.3.0'
}

Flutter doctor

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[βœ“] Flutter (Channel stable, 1.22.3, on Linux, locale en_US.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    βœ— Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.
[!] Android Studio (not installed)
[!] IntelliJ IDEA Ultimate Edition (version 2020.2)
    βœ— Flutter plugin not installed; this adds Flutter specific functionality.
    βœ— Dart plugin not installed; this adds Dart specific functionality.
[βœ“] Connected device (1 available)

! Doctor found issues in 3 categories.

Flutter dependencies

Click To Expand
Dart SDK 2.10.3
Flutter SDK 1.22.3
firebase_test 1.0.0+1

dependencies:
- cupertino_icons 1.0.0
- firebase_analytics 6.1.0 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface]
- firebase_core 0.5.1 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_messaging 7.0.3 [meta flutter firebase_core]
- firebase_remote_config 0.4.1 [flutter firebase_core]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- async 2.5.0-nullsafety.1 [collection]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- clock 1.1.0-nullsafety.1
- collection 1.15.0-nullsafety.3
- fake_async 1.2.0-nullsafety.1 [clock collection]
- firebase 7.3.2 [http http_parser js]
- firebase_analytics_platform_interface 1.0.3 [flutter meta]
- firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- js 0.6.2
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- path 1.8.0-nullsafety.1
- pedantic 1.9.2 [meta]
- plugin_platform_interface 1.0.3 [meta]
- quiver 2.1.4+1 [matcher meta]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- stack_trace 1.10.0-nullsafety.1 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.3 [collection]
- vector_math 2.1.0-nullsafety.3

27 Answers

βœ”οΈAccepted Answer

Fixed for me by using implementation platform('com.google.firebase:firebase-bom') instead of implementation platform('com.google.firebase:firebase-bom:26.2.0')

Other Answers:

Ran into this terrible bug. Put my 2 hours behind so I decided to make a fix for it with the recommended things above and put it on my repo. You can use the following in your pubspec.yaml file

# TODO: Check when this bug (https://github.com/FirebaseExtended/flutterfire/issues/4035) is fixed and swap back to official package
  firebase_remote_config:
    git:
      url: https://github.com/FilledStacks/flutterfire.git
      path: packages/firebase_remote_config

My app/build.gradle file looks like this

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:26.0.0')
    // When using the BoM, you don't specify versions in Firebase library dependencies
    // Declare the dependency for the Firebase SDK for Google Analytics
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-config'
    // implementation 'com.google.firebase:firebase-auth-ktx'
    implementation 'com.google.android.gms:play-services-basement'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

That takes care of the fix. I will leave this repo up but when this bug is fixed you should swap back to the official package.

Expecting fix soon!

A workaround for a temporary fix, Go to your pub cache dir, find MethodCallHandler.java and replace this line:

properties.put("inDebugMode", firebaseRemoteConfigInfo.getConfigSettings().isDeveloperModeEnabled());
with
properties.put("inDebugMode", false);

Also, change the following

FirebaseRemoteConfigSettings settings = new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(debugMode).build();
firebaseRemoteConfig.setConfigSettings(settings);

with

FirebaseRemoteConfigSettings settings = new FirebaseRemoteConfigSettings.Builder().build();
firebaseRemoteConfig.setConfigSettingsAsync(settings);

In my case it worked after commenting Firebase-bom dependency [implementation platform('com.google.firebase:firebase-bom:26.1.0')] and given versions manually for other firebase dependencies.

More Issues: