Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android firebase:firebase配置:16.0.0不工作_Android_Firebase - Fatal编程技术网

Android firebase:firebase配置:16.0.0不工作

Android firebase:firebase配置:16.0.0不工作,android,firebase,Android,Firebase,我做每件事都是遵循规则。但是mFirebaseRemoteConfig.fetch(cacheExpiration)没有工作 但是当我在我的应用程序中将一个版本更改为早期版本时 implementation 'com.google.firebase:firebase-config:16.0.0' 到 它开始工作了 你知道这是什么原因吗 我还检查了我以前的项目。我将版本从11.0.4更改为16.0.0,取回停止工作 我的应用程序构建梯度: apply plugin: 'com.android.a

我做每件事都是遵循规则。但是mFirebaseRemoteConfig.fetch(cacheExpiration)没有工作

但是当我在我的应用程序中将一个版本更改为早期版本时

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

它开始工作了

你知道这是什么原因吗

我还检查了我以前的项目。我将版本从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'
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
}
我的项目梯度文件

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'
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 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();
            }
        });
我想问题出在你身上。。但是现在我在模拟器的扩展窗口中找不到Google Play设置。。如果我是对的,有没有其他方法可以在emulator上更新Google Play服务

这是我的SDK设置

使用“显示包详细信息”:

您需要添加:

 implementation 'com.google.firebase:firebase-core:16.0.0'
您的应用程序gradle文件现在必须明确列出com.google.firebase:firebase核心,作为firebase服务按预期工作的依赖项

更多信息请点击此处:


是的,问题出在emulator中。但我也发现最好通过
GoogleAppAvailability.makeGooglePlayServicesAvailable()
方法检查设备是否有兼容的Google Play服务。 看

这是我的验证方法,我在onCreate()调用它:


我也面临同样的问题。我刚刚用maven
{url'替换了
google()https://maven.google.com“}
,然后它开始工作


请参阅快速启动应用程序。

您所说的“没有工作”是什么意思?logcat说什么?这意味着
public void onComplete(@NonNull Task Task)
没有被调用。我在问题中添加了它。:
06-04 17:39:55.966 10786-10826/com.bestworldgames.bestwordgame W/GooglePlayServicesUtil:googleplay服务过时了。需要12451000,但找到11509470 06-04 17:39:55.966 10786-10786/com.bestworldgames.bestwordgame W/FA:服务连接失败:连接结果{状态码=服务版本\需要更新,分辨率=空,消息=空}
,我想问题在模拟器中。。但是现在我在emulator的扩展窗口中找不到Google Play设置…),对不起,我刚刚添加了一个gradle文件代码。我已经有这个了:
06-04 17:39:55.966 10786-10826/com.bestworldgames.bestwordgame W/GooglePlayServicesUtil:googleplay服务过时了。需要12451000,但找到11509470 06-04 17:39:55.966 10786-10786/com.bestworldgames.bestwordgame W/FA:服务连接失败:连接结果{statusCode=Service\u VERSION\u UPDATE\u REQUIRED,resolution=null,message=null}
是否使用genymotion?,否,我使用Android Studiotry中提供的AVD并在物理设备上测试,检查问题是否也发生
 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);
        }
    }