使用Firebase时,GoogleSignIn被标记为内部,不应从应用程序访问

喜欢

我正在尝试在我的Android应用中检索已登录用户的联系电子邮件的列表。此处的教程开始,以下行:

mGoogleSignInClient = GoogleSignIn.getClient(this, gso);

导致Android Studio错误“ GoogleSignIn被标记为内部,不应从应用程序访问”。

该项目可以编译,但是当我尝试登录时,logcat输出:

W/GooglePlayServicesUtil: Google Play services out of date.  Requires 12210000 but found 11947470

我的app/gradle.build包含:

dependencies {
    ...
    implementation 'com.google.android.gms:play-services-auth:12.0.0'
    implementation 'com.google.firebase:firebase-core:12.0.0'
    implementation 'com.google.firebase:firebase-firestore:12.0.0'
}
apply plugin: 'com.google.gms.google-services'

当我注释掉Firebase时:

dependencies {
    ...
    implementation 'com.google.android.gms:play-services-auth:12.0.0'
    //implementation 'com.google.firebase:firebase-core:12.0.0'
    //implementation 'com.google.firebase:firebase-firestore:12.0.0'
}
//apply plugin: 'com.google.gms.google-services'

我没有收到错误并成功登录。

我想将Firestorm集成到我的应用程序中,是否需要重新设计登录过程?如果是这样,怎么办?

要复制,这是我的MainActivity编译Firebase后,Log.w调用输出signInResult:failed code=12500

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    static final int RC_SIGN_IN = 1000;
    GoogleSignInClient mGoogleSignInClient;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();
        mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
        findViewById(R.id.google_sign_in_button).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        startActivityForResult(mGoogleSignInClient.getSignInIntent(), RC_SIGN_IN);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == RC_SIGN_IN) {
            Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
            handleSignInResult(task);
        }
    }

    private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
        try {
            GoogleSignInAccount account = completedTask.getResult(ApiException.class);
        } catch (ApiException e) {
            Log.w("signInResult:failed code=" + e.getStatusCode());
        }
    }
}

和我的布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.XXX.MainActivity">
    <com.google.android.gms.common.SignInButton
        android:id="@+id/google_sign_in_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
N1hk

https://developers.google.com/android/guides/releases

版本12.0.0的已知问题

...

  • 注释会导致虚假的皮棉错误,声称GoogleSignIn和CredentialsClient仅限内部使用。这些可以安全地忽略。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

NavigationView setNavigationItemSelectedListener此API被标记为支持库的内部,不应从应用程序访问

对于新的Google Play服务实施,“ GoogleSignIn被标记为内部,不应从应用访问”

应用程序修剪时将整个程序集标记为动态访问

您不应从应用程序主线程调用getWriteableDatabase()

最小化并单击应用程序图标,应用程序不应从启动启动

由于GoogleSignIn,AdMob提交应用程序“应用程序尝试访问没有使用说明的隐私敏感数据”时,iOS 10 GM发布错误

在我的应用程序中删除项目时,如何将提醒标记为已完成?

在“调用应用程序”阶段将inputText标记为无效

WaitForStatus将应用程序标记为“无响应”

-[FBSession checkThreadAffinity]中的断言失败导致应用程序崩溃,“ FBSession:仅应从单个线程使用”

如何在我的 Flutter 应用程序中添加标记为 fabourtie 图标?

通过CDS注释在Fiori应用程序中将字段标记为必填

当所有bean都标记为惰性时,Spring Boot应用程序无法启动,因为它找不到错误通道

从Android应用程序调用异步Firebase函数时获取“内部”异常

内部使用的Facebook应用程序

使用相同的主机名对应用程序进行内部和外部访问?

尝试从 Firebase 部署的 NextJs 应用程序访问 NestJs Google VM 服务器时出错

如果标记为 DPI 感知并与多个监视器一起使用,Winforms 应用程序将抛出 Win32Exception

使用 firebase 的应用程序/无应用程序错误

在离子推送通知中访问应用程序内部的标题

如何从应用程序内部访问JBoss数据目录?

从应用程序内部访问glassfish安全领域

如何让用户访问应用程序的内部存储目录?

iOS:如何从应用程序的UNNotificationServiceExtension内部访问保存的数据?

从React应用程序内部访问Bootstrap方法

Firebase函数无法在应用程序中使用调用函数,返回内部错误

使用应用程序工厂模式时,如何从嵌入式Dash应用程序中访问Flask应用程序的上下文?

Flyway Spring Boot应用程序在启动时不应用插入脚本

如何接收正确的网址?尝试从Firebase应用程序中的googlesignin帐户获取个人资料图片