我们Default FirebaseApp is not initialized in this process com.example.app. Make sure to call FirebaseApp.initializeApp(Context) first.在Android应用中看到了一些例外情况,我们刚刚添加了Firebase远程配置.
堆栈跟踪如下:
Fatal Exception: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.app. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.remoteconfig.FirebaseRemoteConfig.getInstance(Unknown Source)
at com.example.app.fragments.SomeFragment.updateFooter(SourceFile:295)
at com.example.app.fragments.SomeFragment.onCreateView(SourceFile:205)
at android.support.v4.app.Fragment.performCreateView(SourceFile:2080)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1108)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1290)
at android.support.v4.app.BackStackRecord.run(SourceFile:801)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(SourceFile:1638)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(SourceFile:679)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(SourceFile:143)
at android.support.v4.view.ViewPager.populate(SourceFile:1240)
at android.support.v4.view.ViewPager.populate(SourceFile:1088)
at android.support.v4.view.ViewPager.setAdapter(SourceFile:542)
at com.example.app.SomeActivity.onSomeAsyncCallback(SourceFile:908)
at com.example.app.SomeDataRetriever.onAsyncHttpCompleted(SourceFile:72)
at com.example.app.io.AsyncHttp.onPostExecute(SourceFile:141)
at com.example.app.io.AsyncHttp.onPostExecute(SourceFile:19)
at android.os.AsyncTask.finish(AsyncTask.java:679)
at android.os.AsyncTask.access$500(AsyncTask.java:180)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:696) …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Firebase的新远程配置功能来获取远程配置参数,我遇到了问题.
我正在我的应用程序中进行获取和更新onCreate():
final FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
remoteConfig.fetch().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
remoteConfig.activateFetched();
}
}
});
Run Code Online (Sandbox Code Playgroud)
这就是我读它的方式:
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
String value = remoteConfig.getString("active_subscriptions");
Run Code Online (Sandbox Code Playgroud)
值返回null.
如果我打电话remoteConfig.getInfo().getLastFetchStatus(),它会返回LAST_FETCH_STATUS_SUCCESS,所以看起来fetch成功了.
知道为什么我的价值是空白的吗?
我正在使用Firebase Core和其他一些功能,但没有使用Remote Config。每秒多次在Logcat上显示以下输出。
我在哪里可以禁用远程配置功能,甚至可以设置那些不存在的值?
依存关系:
// Project
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.firebase:firebase-plugins:1.2.0'
classpath 'io.fabric.tools:gradle:1.26.1'
// Module
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-messaging:17.5.0'
implementation 'com.google.firebase:firebase-perf:16.2.4'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.jsibbold:zoomage:1.2.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
Run Code Online (Sandbox Code Playgroud)
W/FirebaseRemoteConfig: No value of type 'String' exists for parameter key 'sessions_max_length_minutes'.
W/FirebaseRemoteConfig: No value of type 'String' exists for parameter key 'sessions_max_length_minutes'.
W/FirebaseRemoteConfig: …Run Code Online (Sandbox Code Playgroud) 我正在尝试实施Firebase远程配置:
override fun onCreate(savedInstanceState: Bundle?) {
val configSettings = FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(BuildConfig.DEBUG).build()
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance()
mFirebaseRemoteConfig.setConfigSettings(configSettings)
mFirebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults)
fetchRemoteConfig()
}
private fun fetchRemoteConfig() {
var cacheExpiration = 3600L
if (mFirebaseRemoteConfig.info.configSettings.isDeveloperModeEnabled) {
cacheExpiration = 0L
}
mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener { task ->
if (task.isSuccessful) {
Log.d(TAG, "Remote config fetch succeeded")
mFirebaseRemoteConfig.activateFetched()
} else {
Log.d(TAG, "Remote config fetch failed - ${task.exception?.message}")
}
setupView()
}
}
private fun setupView() {
val text = mFirebaseRemoteConfig.getString("my_text")
//...
}
Run Code Online (Sandbox Code Playgroud)
我的问题是并不总是调用OnCompleteListener.如果我多次关闭/打开我的应用程序,则不会始终触发setupView().
应该始终调用OnCompleteListener吗?即使我正在打缓存?
编辑:即使我禁用开发者模式,行为也是一样的.有时会触发回调,有时不会.
我正在使用Firebase构建一个Web应用程序,我看到他们发布了具有所有强大新功能的扩展.但是,"远程配置"部分现在仅适用于Android和IOS应用程序.有没有办法在Web应用程序上也应用远程配置?
注意:为了澄清这不是Firebase API密钥,这可能更像是一个令牌......客户端应用程序拥有的东西,以及服务器端点验证.
我们正在尝试更好地保护API密钥(认为用于验证客户端到端点的令牌).这将全部在我们的内部网络上,但我们仍然希望确保只有我们的移动客户端可以调用端点.
我以为我们可以将API密钥放在Firebase远程配置参数中(应用程序内置了无效的默认值).但是,远程配置的Firebase文档说:
请勿将机密数据存储在Remote Config参数键或参数值中.可以解码存储在项目的"远程配置"设置中的任何参数键或值.
我不确定这是仅仅指的是与应用程序捆绑在一起的默认值,还是它也适用于远程加载的值.获得密钥后,我们可以对其进行加密,并通过我们的MDM提供商将其存储在设备上.
是否将远程配置数据传输到应用程序加密或完成明文?
感谢任何人都可以提供有关远程配置的更多信息.
我有以下远程config_default.xml文件
<?xml version="1.0" encoding="utf-8"?>
<defaultsMap>
<entry>
<key>LOCAL_JSON</key>
<value>[{"title":"TitleA","path":"pathA","image_url":" Some URL A"},{"title":"TitleB","path":"pathB","image_url":" Some URL B"}]</value>
</entry>
</defaultsMap>
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试使用Firebase远程配置getString()方法访问它时,我总是得到没有引号的字符串
"[{title:TitleA,path:pathA,image_url: Some URL A},{title:TitleB,path:pathB,image_url: Some URL B}]"§
Run Code Online (Sandbox Code Playgroud)
如下图所示
我在Firebase远程配置控制台上放了相同的字符串,一旦应用程序从那里取出它,就会将双引号放在字符串中,就像我期望的那样.
我仔细检查了这一点,当我使用以下项目gradle文件时它似乎工作正常
apply plugin: 'com.github.ben-manes.versions'
buildscript {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.13.0'
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.2.1'
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.google.firebase:firebase-plugins:1.0.5'
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
maven { url "http://oss.sonatype.org/content/repositories/snapshots" }
maven { url …Run Code Online (Sandbox Code Playgroud) android firebase android-gradle-plugin firebase-remote-config android-gradle-3.0
我目前正在对Firebase中的远程配置值运行A/B测试.测试的目标是具有正则表达式中包含的用户属性X的用户.
我的问题是我在设置用户属性之前为用户获取远程配置,因此我需要在设置用户属性时更新远程配置.基本上,远程配置的强制更新(由于用户现在是AB测试的一部分而更新).
有任何想法吗?
我为Android配置了Firebase远程配置A/B测试,我们在至少10K设备上进行了部署.出于某种原因,我在超过24小时后的A/B测试中看到"0个用户".
Firebase GMS版本为:11.8.0
它应该实时显示A/B参与者还是24小时后可以看到0个用户?
PS:我们能够通过Firebase实例ID在测试设备上获得AB测试变体,它运行良好.
运行最简单的实验只有app包作为目标,没有额外的过滤器.它也显示了0个用户.
Firebase 远程配置activateFetched()已弃用。用什么代替?
firebaseRemoteConfig.activateFetched();
Run Code Online (Sandbox Code Playgroud)