Firebase控制台支持简单的方法来配置远程配置参数.
在我们的应用程序中,我们为每个用户提供不同的远程配置,这些配置在我们自己的Web门户上设置.
是否有任何API可以将配置从我自己的门户网站推送到Firebase远程配置服务器,然后在Android应用程序上使用远程配置lib来获取新配置?
Firebase远程配置应用程序版本条件似乎被忽略.我已经进行了以下设置以使用我当前的开发版本:
FIRRemoteConfig不会返回正确的参数值.
编辑:我应该强调,我有口味,我不想使用任何这些谷歌服务,并尝试在这种情况下应用谷歌服务插件,没有适用的google-services.json,将导致构建失败.
我希望能够初始化Firebase SDK,特别是使用远程配置,不使用google-services.json.
我看到FirebaseApp有一个初始化方法,它接收一个FirebaseOptions对象.
我使用google-services.json中提供的值构建了FirebaseOptions,在使用这些选项调用FirebaseApp.initialize之后,我总是得到
FirebaseInitProvider: FirebaseApp initialization unsuccessful
Run Code Online (Sandbox Code Playgroud)
我知道这是使用google-services.json文件的推荐方法,但我需要能够让应用程序调用不同的Firebase项目,具体取决于调试/发布版本,同时保持包名称相同.
我想这样做的方法是为初始化Firebase所需的所有值设置调试/释放对,然后动态地进行初始化.
FirebaseOptions options = new FirebaseOptions.Builder()
.setApplicationId(appId)
.setApiKey(apiKey)
.setGcmSenderId(appContext.getString(
isDebug ? R.string.firebase_testing_gcm_sender_id :
R.string.firebase_production_gcm_sender_id))
.setDatabaseUrl(appContext.getString(
isDebug ? R.string.firebase_testing_database_url :
R.string.firebase_production_database_url))
.setStorageBucket(
appContext.getString(
isDebug ? R.string.firebase_testing_storage_bucket :
R.string.firebase_production_storage_bucket))
.build();
FirebaseApp.initializeApp(appContext, options);
Run Code Online (Sandbox Code Playgroud)
到目前为止它似乎没有用.
非常感谢所有帮助!
每当我致电时FirebaseRemoteConfig.getInstance(),都会收到以下警告:
W/zze: Application name is not set. Call Builder#setApplicationName.
我已经从Firebase更新了json配置文件,但它保持不变。它不影响任何功能,但是我不禁认为缺少某些东西。我在某处可能缺少的任何配置?
我正在使用Firebase远程配置,我正试图围绕应用程序版本条件.
https://firebase.google.com/docs/remote-config/parameters#rule_types说我必须对它进行字符串匹配.
但我真的需要一种方法来说parameter_x在不同的版本范围内会有不同的值.
有没有办法做到这一点,或者我是不是想出一个荒谬的正则表达式?
将Firebase库升级到
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation 'com.google.firebase:firebase-config:17.0.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
Run Code Online (Sandbox Code Playgroud)
并同步Gradle,我得到警告:
'setConfigSettings(FirebaseRemoteConfigSettings!): Unit' is deprecated. Deprecated in Java
'setDeveloperModeEnabled(Boolean): FirebaseRemoteConfigSettings.Builder!' is deprecated. Deprecated in Java
Run Code Online (Sandbox Code Playgroud)
在这些行中:
//Setting Developer Mode enabled to fast retrieve the values
firebaseRemoteConfig.setConfigSettings(
FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(BuildConfig.DEBUG)
.build())
Run Code Online (Sandbox Code Playgroud) RemoteConfig的Firebase API有几种按命名空间分配配置值的方法,例如(setDefaults(R.xml.rc_defaults, "Namespace")).我已经通过Android上的命名空间分离配置值,但是如何在Firebase控制台上按命名空间设置这些值以进行远程更新?
添加RemoteConfig.
2020-04-02 16:47:06.844 12100-12100/removed W/ComponentDiscovery: Class com.google.firebase.remoteconfig.ktx.FirebaseConfigKtxRegistrar is not an found.
java.lang.ClassNotFoundException: com.google.firebase.remoteconfig.ktx.FirebaseConfigKtxRegistrar
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at java.lang.Class.forName(Class.java:378)
at com.google.firebase.components.ComponentDiscovery.instantiate(com.google.firebase:firebase-components@@16.0.0:80)
at com.google.firebase.components.ComponentDiscovery.discover(com.google.firebase:firebase-components@@16.0.0:73)
at com.google.firebase.FirebaseApp.<init>(com.google.firebase:firebase-common@@19.3.0:404)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:300)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:268)
at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:253)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@19.3.0:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1927)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1902)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@19.3.0:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:6528)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6021)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5927)
at android.app.ActivityThread.access$1200(ActivityThread.java:200)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1673)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.remoteconfig.ktx.FirebaseConfigKtxRegistrar" on path: DexPathList[[zip file "/data/app/removed-VBiXJeGazGh2qyHGB8IDBA==/base.apk"],nativeLibraryDirectories=[/data/app/removed-VBiXJeGazGh2qyHGB8IDBA==/lib/arm64, /system/lib64, /vendor/lib64]]
at …Run Code Online (Sandbox Code Playgroud) Android 的所有 Firebase 服务都无法在华为上运行还是只是云消息服务不起作用?所有的 Firebase 服务都依赖于 Google Play 服务吗?
firebase google-play-services firebase-realtime-database firebase-remote-config huawei-mobile-services