Google 播放服务已过时。需要 12800000 但找到 8703448

Google Play services out of date. Requires 12800000 but found 8703448

我的应用使用了以下依赖项

implementation 'com.google.android.gms:play-services-auth:16.0.1'

它连接到 Google Api 以获取设备位置并将数据存储在 Google 智能锁中。

除了在一台设备上 运行ning 在 Android 6 上,它工作正常。 尝试连接到 Google Api 时,出现以下错误:

ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED

W/GooglePlayServicesUtil: Google Play services out of date. Requires 12800000 but found 8703448

我无法返回到以前版本的播放服务库,因为 Android Studio 说

ERROR: All firebase libraries must be either above or below 14.0.0

我应该怎么做才能让该应用程序可以 运行 在 Google Play 服务版本过时的设备上?

我通过使用此代码更新 Google 播放服务版本解决了错误,

            //On button click of the google signIn 

             googleSignIn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent signInIntent = mGoogleSignInClient.getSignInIntent();
            startActivityForResult(signInIntent,GOOGLE_SIGNIN_ID);
            }


    //onActivity Result code.
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent 
  data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == GOOGLE_SIGNIN_ID){
        Task<GoogleSignInAccount> googleSignInAccountTask = GoogleSignIn.getSignedInAccountFromIntent(data);
        try {

            GoogleSignInAccount googleSignInAccount = googleSignInAccountTask.getResult(ApiException.class);
            fireBaseAuthenticationWithGoogle(googleSignInAccount);

        }catch (ApiException e){

            //if user doesn't have updated google play services version

            if (e.getStatusCode() == 12500){

                try{
                    // show your own AlertDialog for example:
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    // set the message
                    builder.setMessage("This app uses google play services for signing in")
                            .setTitle("Do you want to update?");

                    builder.setPositiveButton("Ok", (dialog, id) -> {

                        //final String appPackageName = "com.google.android.gms";
                        final String appPackageName = "com.google.android.gms&hl=en_IN";
                        try {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
                        }catch (android.content.ActivityNotFoundException anfe) {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
                        }
                    });
                    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            // User cancelled the dialog
                        }
                    });
                    AlertDialog dialog = builder.create();
                    dialog.show();
                }catch (Exception err){
                    err.printStackTrace();
                }

            }
        }
    }

把这个放在你得到异常的地方。我希望它能帮助@matdev。