Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.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 6+;中的Google Play services错误;?_Android_Google Play Services - Fatal编程技术网

如何解决Android 6+;中的Google Play services错误;?

如何解决Android 6+;中的Google Play services错误;?,android,google-play-services,Android,Google Play Services,当我使用Firebase时,我需要检查我在应用程序启动时是否有受支持版本的Google Play Services。Google PlayServiceSutil已被弃用。因此,我正在使用新的闪亮的GoogleAppAvailability api,我可以检测是否需要升级 但是,当我使用is时,它不会启动所需的意图。它没有任何作用。互联网上的搜索没有发现任何有用的代码示例。理想情况下,我想编写自己的自定义对话框并启动PendingEvent,但这也是难以捉摸的。我的代码: final G

当我使用Firebase时,我需要检查我在应用程序启动时是否有受支持版本的Google Play Services。Google PlayServiceSutil已被弃用。因此,我正在使用新的闪亮的GoogleAppAvailability api,我可以检测是否需要升级

但是,当我使用is时,它不会启动所需的意图。它没有任何作用。互联网上的搜索没有发现任何有用的代码示例。理想情况下,我想编写自己的自定义对话框并启动PendingEvent,但这也是难以捉摸的。我的代码:

    final GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
    final int resultCode = googleAPI.isGooglePlayServicesAvailable(this);
    if (resultCode == ConnectionResult.SUCCESS) {
        if (isOnline()) {
            app.init(this, this);
        }
    } else {
            switch (resultCode) {
                case SERVICE_VERSION_UPDATE_REQUIRED:
                    Dialog updateDialog = googleAPI.getErrorDialog(this, resultCode, PLAY_SERVICES_RESOLUTION_REQUEST, mOnCancelFinishApp);
                    updateDialog.setOnDismissListener(mOnDismissFinishApp);
                    updateDialog.setCanceledOnTouchOutside(false);
                    updateDialog.show();
                    ...
更新:我的gradle有这些依赖项

.....
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile('com.microsoft.aad:adal:2.0.1-alpha') {
        exclude group: 'com.android.support'
    }
    compile 'com.google.android.gms:play-services-location:10.0.0'
    compile('com.crashlytics.sdk.android:answers:1.3.12@aar') {
        transitive = true;
    }
    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:support-v4:25.0.0'
    compile 'com.google.android.gms:play-services-maps:10.0.0'
    compile 'com.google.android.gms:play-services-location:10.0.0'
    compile 'com.android.support:cardview-v7:25.0.0'
    compile 'com.google.android.gms:play-services-analytics:10.0.0'
    compile 'com.google.firebase:firebase-core:10.0.0'
    provided 'org.glassfish:javax.annotation:10.0-b28'
}
apply plugin: 'com.google.gms.google-services'

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        // These docs use an open ended version so that our plugin
        // can be updated quickly in response to Android tooling updates

        // We recommend changing it to the latest version from our changelog:
        // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }

请检查Google PlayServices是否可用

Dialog errorDialog;

private boolean checkPlayServices() {

        GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();

        int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(this);

        if (resultCode != ConnectionResult.SUCCESS) {
            if (googleApiAvailability.isUserResolvableError(resultCode)) {

                if (errorDialog == null) {
                    errorDialog = googleApiAvailability.getErrorDialog(this, resultCode, 2404);
                    errorDialog.setCancelable(false);
                }

                if (!errorDialog.isShowing())
                    errorDialog.show();

            }
        }

        return resultCode == ConnectionResult.SUCCESS;
    }

请尝试以下更改:

....
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }


buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    // These docs use an open ended version so that our plugin
    // can be updated quickly in response to Android tooling updates

    // We recommend changing it to the latest version from our changelog:
    // https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
    classpath 'io.fabric.tools:gradle:1.+'
 }
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

compile('com.microsoft.aad:adal:2.0.1-alpha') {
    exclude group: 'com.android.support'
}
compile 'com.google.android.gms:play-services-location:10.0.0'
compile('com.crashlytics.sdk.android:answers:1.3.12@aar') {
    transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
    transitive = true;
}
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.google.android.gms:play-services-maps:10.0.0'
compile 'com.android.support:cardview-v7:25.0.0'
compile 'com.google.android.gms:play-services-analytics:10.0.0'
compile 'com.google.firebase:firebase-core:10.0.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
}

apply plugin: 'com.google.gms.google-services'

请更新您的gradlefile@YogeshBorhade我已经从我的gradle文件中包含了依赖项。请发布你的gradle文件
:播放服务位置:
2次这似乎是从我看到的其他答案中复制的,不适用于棉花糖。