com.google.firebase: firebase-config: 16.0.0 не работает - PullRequest
0 голосов
/ 04 июня 2018

Я сделал все, следуя инструкциям .Но mFirebaseRemoteConfig.fetch(cacheExpiration) не работал.

Но когда я изменил версию более ранней в своем файле gradle сборки приложения с

implementation 'com.google.firebase:firebase-config:16.0.0'

на

implementation 'com.google.firebase:firebase-config:11.0.4'

, она стала работать ..

У вас есть идеи, что может быть причиной этого?

Также я проверял свои предыдущие проекты.Я изменил версию с 11.0.4 на 16.0.0 и загрузка перестала работать ...

мой сборщик приложений :

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'

мой проектфайл Gradle :

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
}

Добавлено:

mFirebaseRemoteConfig.fetch(cacheExpiration) не работает означает, что public void onComplete(@NonNull Task<Void> task) не был вызван.

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}

Я полагаю, что проблема в эмуляторе ... Но теперь я не могу найти настройки Google Play в расширенном окне эмулятора. Если я прав,Есть ли другой способ обновить сервисы Google Play на эмуляторе?

Это мои настройки SDK enter image description here

с «Показать сведения о пакете»:

enter image description here

Ответы [ 3 ]

0 голосов
/ 07 июня 2018

Да, проблема в эмуляторе.Но также я обнаружил, что лучше проверить устройство на совместимые сервисы Google Play методом GoogleApiAvailability.makeGooglePlayServicesAvailable().См. ссылку .

Это мой метод проверки, который я вызываю по 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);
        }
    }
0 голосов
/ 12 июля 2018

Столкнулся с такой же проблемой.Я просто заменил google() на maven { url 'https://maven.google.com' }, затем он начал работать.

См. Приложение быстрого запуска здесь .

0 голосов
/ 04 июня 2018

Вам нужно добавить:

 implementation 'com.google.firebase:firebase-core:16.0.0'

Теперь в файле gradle вашего приложения должен явно указываться com.google.firebase: firebase-core как зависимость для служб Firebase, чтобы работать должным образом.

подробнее здесь:

https://firebase.google.com/support/release-notes/android

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...