Flutterfire: 🐛 [firebase_remote_config: 0.4.1] Plugin using removed method, causing app to crash

Created on 5 Nov 2020  ·  12Comments  ·  Source: FirebaseExtended/flutterfire

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


crowd remote_config bug crash

Most helpful comment

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);

All 12 comments

Reproducible on the latest flutter master 1.24.0-8.0.pre.97 with firebase_remote_config: ^0.4.1.


flutter doctor -v

[√] Flutter (Channel master, 1.24.0-8.0.pre.97, on Microsoft Windows [Version 10.0.19041.572], locale et-EE)
    • Flutter version 1.24.0-8.0.pre.97 at C:\Development\flutter_master
    • Framework revision 4c24eb10b8 (5 hours ago), 2020-11-05 11:18:00 +0100
    • Engine revision e66a720137
    • Dart version 2.12.0 (build 2.12.0-21.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at C:\Users\marku\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6858069\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.7.30621.155
    • Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6858069
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] IntelliJ IDEA Ultimate Edition (version 2020.2)
    • IntelliJ at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\202.7660.26
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] Connected device (5 available)
    • SM G950F (mobile) • ce12171c51cc001c03 • android-arm64  • Android 9 (API 28)
    • Windows (desktop) • windows            • windows-x64    • Microsoft Windows [Version 10.0.19041.572]
    • Web Server (web)  • web-server         • web-javascript • Flutter Tools
    • Chrome (web)      • chrome             • web-javascript • Google Chrome 86.0.4240.183
    • Edge (web)        • edge               • web-javascript • Microsoft Edge 86.0.622.61

• No issues found!



Logs

[ +189 ms] E/AndroidRuntime( 1560): FATAL EXCEPTION: main
[        ] E/AndroidRuntime( 1560): Process: com.nevercode.triage, PID: 1560
[        ] E/AndroidRuntime( 1560): 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/com.nevercode.triage-5371QSn-DxEXPwPMcverRA==/base.apk!classes2.dex)
[        ] E/AndroidRuntime( 1560):     at io.flutter.plugins.firebase.firebaseremoteconfig.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:45)
[        ] E/AndroidRuntime( 1560):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
[        ] E/AndroidRuntime( 1560):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
[        ] E/AndroidRuntime( 1560):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:693)
[        ] E/AndroidRuntime( 1560):     at android.os.MessageQueue.nativePollOnce(Native Method)
[        ] E/AndroidRuntime( 1560):     at android.os.MessageQueue.next(MessageQueue.java:326)
[        ] E/AndroidRuntime( 1560):     at android.os.Looper.loop(Looper.java:181)
[        ] E/AndroidRuntime( 1560):     at android.app.ActivityThread.main(ActivityThread.java:7050)
[        ] E/AndroidRuntime( 1560):     at java.lang.reflect.Method.invoke(Native Method)
[        ] E/AndroidRuntime( 1560):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
[        ] E/AndroidRuntime( 1560):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
[  +20 ms] I/Process ( 1560): Sending signal. PID: 1560 SIG: 9
[ +107 ms] Service protocol connection closed.
[        ] Lost connection to device.

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);

some issue.

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

This workaround works

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);

I couldn't do this as the file doesn't have any line as described. Any ideas?

// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.share;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import java.util.Map;

/** Handles the method calls for the plugin. */
class MethodCallHandler implements MethodChannel.MethodCallHandler {

  private Share share;

  MethodCallHandler(Share share) {
    this.share = share;
  }

  @Override
  public void onMethodCall(MethodCall call, MethodChannel.Result result) {
    if (call.method.equals("share")) {
      if (!(call.arguments instanceof Map)) {
        throw new IllegalArgumentException("Map argument expected");
      }
      // Android does not support showing the share sheet at a particular point on screen.
      share.share((String) call.argument("text"), (String) call.argument("subject"));
      result.success(null);
    } else {
      result.notImplemented();
    }
  }
}

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.

Any updates on this?? its really a blocker

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);

I couldn't do this as the file doesn't have any line as described. Any ideas?

// Copyright 2019 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.share;

import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import java.util.Map;

/** Handles the method calls for the plugin. */
class MethodCallHandler implements MethodChannel.MethodCallHandler {

  private Share share;

  MethodCallHandler(Share share) {
    this.share = share;
  }

  @Override
  public void onMethodCall(MethodCall call, MethodChannel.Result result) {
    if (call.method.equals("share")) {
      if (!(call.arguments instanceof Map)) {
        throw new IllegalArgumentException("Map argument expected");
      }
      // Android does not support showing the share sheet at a particular point on screen.
      share.share((String) call.argument("text"), (String) call.argument("subject"));
      result.success(null);
    } else {
      result.notImplemented();
    }
  }
}

How did you find the MethodCallHandler.java file ?? i been trying to find it the whole day with now luck

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

This workaround works

how did u find the file ? can you provide more details plz

-- SOLVED by CMD + SHIFT + . 👍

🥇 🥇 🥇 🥇 🥇

Okey not only changing this
properties.put("inDebugMode", firebaseRemoteConfigInfo.getConfigSettings().isDeveloperModeEnabled());
to
properties.put("inDebugMode", false);

& changing this

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

You need also to change this

FirebaseRemoteConfig.getInstance().setDefaults(defaults);
to
FirebaseRemoteConfig.getInstance().setDefaultsAsync(defaults);

Still its an annoying issue and should be solved asap

🥇 🥇 🥇 🥇 🥇

Okey not only changing this
properties.put("inDebugMode", firebaseRemoteConfigInfo.getConfigSettings().isDeveloperModeEnabled());
to
properties.put("inDebugMode", false);

& changing this

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

You need also to change this

FirebaseRemoteConfig.getInstance().setDefaults(defaults);
to
FirebaseRemoteConfig.getInstance().setDefaultsAsync(defaults);

Still its an annoying issue and should be solved asap

I'm interested in knowing how did you find this file. The one that I found does not have the code lines that you're specifying

🥇 🥇 🥇 🥇 🥇
Okey not only changing this
properties.put("inDebugMode", firebaseRemoteConfigInfo.getConfigSettings().isDeveloperModeEnabled());
to
properties.put("inDebugMode", false);
& changing this
FirebaseRemoteConfigSettings settings = new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(debugMode).build();
firebaseRemoteConfig.setConfigSettings(settings);
to
FirebaseRemoteConfigSettings settings = new FirebaseRemoteConfigSettings.Builder().build();
firebaseRemoteConfig.setConfigSettingsAsync(settings);
You need also to change this
FirebaseRemoteConfig.getInstance().setDefaults(defaults);
to
FirebaseRemoteConfig.getInstance().setDefaultsAsync(defaults);
Still its an annoying issue and should be solved asap

I'm interested in knowing how did you find this file. The one that I found does not have the code lines that you're specifying

1- Open this dir /SDK/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_remote_config-0.4.2/android/src/main/java/io/flutter/plugins/firebase/firebaseremoteconfig
2- you will find this file MethodCallHandlerImpl.java

it will contains the same source

Was this page helpful?
0 / 5 - 0 ratings