Reputation: 199
I did everything by following the instructions. But mFirebaseRemoteConfig.fetch(cacheExpiration)
haven't been working.
But when I changed a version to the earlier in my app build gradle file from
implementation 'com.google.firebase:firebase-config:16.0.0'
to
implementation 'com.google.firebase:firebase-config:11.0.4'
it's become working..
Do you have any idea, what can be the reason of it?
Also I checked in my previous projects. I changed the version from 11.0.4 to 16.0.0 and fetching stoped working...
my app build gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.bestworldgames.bestwordgame"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
android.defaultConfig.vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.inkapplications.viewpageindicator:library:2.4.3'
implementation 'com.startapp:inapp-sdk:3.8.4'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {
exclude module: 'support-v4'
}
}
apply plugin: 'com.google.gms.google-services'
my project gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Added:
mFirebaseRemoteConfig.fetch(cacheExpiration)
not working is mean that public void onComplete(@NonNull Task<Void> task)
haven't been called.
mFirebaseRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(MainActivity.this, "Fetch Succeeded",
Toast.LENGTH_SHORT).show();
// After config data is successfully fetched, it must be activated before newly fetched
// values are returned.
mFirebaseRemoteConfig.activateFetched();
} else {
Toast.makeText(MainActivity.this, "Fetch Failed",
Toast.LENGTH_SHORT).show();
}
displayWelcomeMessage();
}
});
logcat:
06-04 17:39:55.966 10786-10826/com.bestwordgame W/GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 11509470
06-04 17:39:55.966 10786-10786/com.bestwordgame W/FA: Service connection failed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null, message=null}
The promlem is in emulator, I guess.. But now I can't find Google Play settings in the emulator's extanded window.. If I'm right, Is there another way to update Google Play Services on emulator?
with 'Show package details':
Upvotes: 0
Views: 1376
Reputation: 274
Faced the same problem. I just replaced the google()
by maven { url 'https://maven.google.com' }
, then it started working.
Refer the quickstart app here.
Upvotes: 0
Reputation: 199
Yes, the problem is in emulator. But also I've found out that it's better to check the device for a compatible Google Play services by GoogleApiAvailability.makeGooglePlayServicesAvailable()
method.
See the link.
It's my verification method, wich I call at onCreate():
private void checkGooglePlayServices() {
GoogleApiAvailability api = GoogleApiAvailability.getInstance();
int status = api.isGooglePlayServicesAvailable(this);
Log.i("TAG", "AppController checkGooglePlayServices status " + status);
if (status != ConnectionResult.SUCCESS) {
api.makeGooglePlayServicesAvailable(this);
}
}
Upvotes: 1
Reputation: 80914
You need to add:
implementation 'com.google.firebase:firebase-core:16.0.0'
Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.
more info here:
https://firebase.google.com/support/release-notes/android
Upvotes: 0