2

我通过 MainActivity.onCreate 获取 FirebaseRemoteConfig 实例。这是简单的 setupCode,但在某些设备上的生产中发生了崩溃。这是堆栈跟踪。我正在使用播放服务 9.0.1。

有什么想法吗?

  protected void onCreate(Bundle savedInstanceState) {

          super.onCreate(savedInstanceState);
          setupFirebaseRemoteConfig(); //line 476
  }


  private void setupFirebaseRemoteConfig() {

          mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();

          FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
                  .setDeveloperModeEnabled(BuildConfig.DEBUG)
                  .build();

          mFirebaseRemoteConfig.setConfigSettings(configSettings);
          mFirebaseRemoteConfig.setDefaults(R.xml.remote_config);

          configCacheExpiration = 3600;

          if (mFirebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
              configCacheExpiration = 0;
          }
      }

  Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{}:

  java.lang.NullPointerException: Attempt to read from field 'int com.google.android.gms.internal.zzaji$zzc.zzbTG' on a null object reference
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
         at android.app.ActivityThread.access$900(ActivityThread.java:172)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loop(Looper.java:145)
         at android.app.ActivityThread.main(ActivityThread.java:5832)
         at java.lang.reflect.Method.invoke(Method.java)
         at java.lang.reflect.Method.invoke(Method.java:372)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
  Caused by java.lang.NullPointerException: Attempt to read from field 'int com.google.android.gms.internal.zzaji$zzc.zzbTG' on a null object reference
         at com.google.firebase.remoteconfig.FirebaseRemoteConfig.zza(Unknown Source)
         at com.google.firebase.remoteconfig.FirebaseRemoteConfig.zzbD(Unknown Source)
         at com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(Unknown Source)
         at com.buscaalimento.android.view.viewcontroller.MainActivity.setupFirebaseRemoteConfig(MainActivity.java:476)
         at com.buscaalimento.android.view.viewcontroller.MainActivity.onCreate(MainActivity.java:455)
         at android.app.Activity.performCreate(Activity.java:6221)
         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
         at android.app.ActivityThread.access$900(ActivityThread.java:172)
         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
         at android.os.Handler.dispatchMessage(Handler.java:102)
         at android.os.Looper.loop(Looper.java:145)
         at android.app.ActivityThread.main(ActivityThread.java:5832)
         at java.lang.reflect.Method.invoke(Method.java)
         at java.lang.reflect.Method.invoke(Method.java:372)
         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
4

2 回答 2

0

当您的依赖项中有不同版本的播放服务或 firebase 时,会发生此错误。所有版本必须相同,例如:11.6.2

于 2017-12-18T16:03:17.430 回答
0

另外,请检查您的 google-services.json 是否是最新的

于 2017-12-18T16:29:20.450 回答