- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
美好的一天
我目前正在开发一款需要谷歌登录的应用。我按照此处提供的 firebase 提供的说明进行操作:https://firebase.google.com/docs/auth/android/google-signin
但是,我从应用程序收到不可靠的登录信息。它运行良好了一段时间,然后开始出现问题。不幸的是,我什至没有太多的趋势可以描述。它主要发生在移动数据上,但有时甚至在 wifi 上也会发生。有时会登录,有时不会。除此之外,有时它会抛出一个 FirebaseNetworkError,有时它什么都不做。我应该提一下,我已经仔细检查过当它失败时总是有可靠的互联网连接(我总是检查 Youtube 视频并在 Chrome 上查找几页)。我还在不同移动和 wifi 网络上的大约 10 种不同的 android 设备上进行了测试。本质上,它有时会登录,有时不会。
我做了很多研究,但没有找到任何东西。如果我遗漏了什么,请告诉我。
编辑:用户登录后就没有问题了。所有其他 Firebase 服务都能完美运行。
这是我的身份验证 Activity (我有一个单独的身份验证,然后启动到我的 Main):
public class Authentication extends AppCompatActivity implements
GoogleApiClient.OnConnectionFailedListener {
private FirebaseAuth mFirebaseAuth;
private GoogleApiClient apiClient;
private static final int RC_SIGN_IN = 9001;
SignInButton button;
Button signOut;
private static final String TAG = "GoogleActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_authentication);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
button = (SignInButton) findViewById(R.id.googleSignIN);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
signIn();
}
});
signOut = (Button) findViewById(R.id.bSignOut);
signOut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
signOut();
}
});
// Set up Google Sign-in options
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();
// Set up Sign-In Api Client
apiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
//mFirebaseAuth = FirebaseAuth.getInstance();
mFirebaseAuth = FirebaseAuth.getInstance();
}
@Override
protected void onStart() {
super.onStart();
// Check if current user is signed in
FirebaseUser currentUser = mFirebaseAuth.getCurrentUser();
startMain(currentUser);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthGoogle(account);
} else {
startMain(null);
}
}
}
private void firebaseAuthGoogle(GoogleSignInAccount account) {
AuthCredential credential = GoogleAuthProvider.getCredential(account.getIdToken(), null);
mFirebaseAuth.signInWithCredential(credential).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
FirebaseUser user = mFirebaseAuth.getCurrentUser();
startMain(user);
} else {
Log.w(TAG, task.getException());
Toast.makeText(Authentication.this, "Authentication Failed. Please try again later", Toast.LENGTH_SHORT).show();
startMain(null);
}
}
});
}
private void signIn() {
Intent signIn = Auth.GoogleSignInApi.getSignInIntent(apiClient);
startActivityForResult(signIn, RC_SIGN_IN);
}
private void signOut() {
mFirebaseAuth.signOut();
Auth.GoogleSignInApi.signOut(apiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
startMain(null);
}
});
}
private void revokeAccess() {
mFirebaseAuth.signOut();
Auth.GoogleSignInApi.revokeAccess(apiClient).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
startMain(null);
}
});
}
private void startMain(FirebaseUser currentUser) {
if (currentUser != null) {
Intent i = new Intent(Authentication.this, MainActivity.class);
startActivity(i);
finish();
}
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Toast.makeText(Authentication.this, "Error", Toast.LENGTH_LONG).show();
}
这是网络错误的堆栈跟踪:
07-01 15:28:19.991 30844-30844/***.*********.******** W/GoogleActivity:
com.google.firebase.FirebaseNetworkException: A network error (such as
timeout, interrupted connection or unreachable host) has occurred.
at
com.google.android.gms.internal.jz.zzK(Unknown Source)
at
com.google.android.gms.internal.jb.zza(Unknown Source)
at
com.google.android.gms.internal.kj.zzL(Unknown Source)
at
com.google.android.gms.internal.kl.onFailure(Unknown Source)
at
com.google.android.gms.internal.kb.onTransact(Unknown Source)
at
android.os.Binder.execTransact(Binder.java:446)
list 权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
项目 gradle 依赖项:
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
模块 gradle 依赖项(相关的):
compile 'com.firebaseui:firebase-ui:2.0.1'
compile 'com.google.firebase:firebase-database:11.0.2'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.google.android.gms:play-services-auth-base:11.0.2'
compile 'com.google.android.gms:play-services-auth:11.0.2'
compile 'com.google.android.gms:play-services-identity:11.0.2'
compile 'com.google.android.gms:play-services-location:11.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-places:11.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-database:11.0.2'
compile 'com.google.firebase:firebase-messaging:11.0.2'
我还在我的 firebase 控制台中启用了 Google 登录,我输入了我的 SHA-1 key ,再次从 firebase 下载了 google-service.json 文件并生成了一个已签名的 apk 并对其进行了测试。
此时我感到非常沮丧,因为它有时有效,有时却无效,因此欢迎并非常感谢您提出任何建议。提前致谢!
最佳答案
我设法解决了这个问题。以下是对可能面临相同问题的任何人的建议:
在 android 监视器中,有一个方便的选项可以仅选择“firebase”日志(请原谅我的天真,我不知道这个)。就我而言,它表明没有网络连接。但是,这是因为 Google 服务在我设备上的移动数据上受到限制。
不过,该问题在其他设备上也仍然存在,因此我也生成了一个发布 SHA-1 key 并将其添加到我的 firebase 项目中。我下载了一个新的 google-services.json 文件并添加了它(我不知道这是否有必要,这只是一种预防措施)。当我无法弄清楚其他任何事情时,我已经在我的其他一些设备上测试了签名的 apk。因此,我认为这解决了其他设备上的登录问题。
关于Android Google Sign-in with Firebase Authentication 登录不可靠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44861616/
我提出这个问题是因为我没有找到关于这 3 个 gpg 选项之间差异的明确解释: gpg --sign file # produces file.gpg gpg --clear-sign
以下网页介绍了将 Google 登录集成到网络应用程序中的简单工作流程: https://developers.google.com/identity/sign-in/web/sign-in 实现代码
Microsoft 最近向 Azure AD B2C 添加了新的“注册或登录”策略。 https://azure.microsoft.com/en-us/documentation/articles/
鉴于此 xml: 如何选择包含 version="@2.15"的元素?我无法弄清楚如何将 @-sign 放入 XPath。 提前致谢, 埃里克 最佳答案 此 XPath 选择所
我正在为我的网站进行 Slack 集成,包括允许用户使用“使用 Slack 登录”按钮登录。理想情况下,我希望它只要求用户授予 identity.*权限一次,然后下次当他们单击“使用 Slack 登录
在将我的第二个应用程序项目上传到 PlayStore 时,在为新版本上传 .aab 文件时出现以下错误: "Your Android App Bundle is signed with the wro
As Math.sign() 接受数字参数或数字作为字符串,如 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Gl
我已经在我的网站上实现了 Sign In with Apple。但问题是它只适用于我开发者的 Apple ID。 我尝试在同一环境中使用我的个人 Apple ID,并且登录过程也运行良好。 但是,当真
Signed Short (Signed Int16) 乘法解释? short ss = -32768; // 0x8000 SHRT_MIN ss *= (short) -1; printf ("%
class Book attr_accessor :author attr_reader :title attr_reader :comments def initialize(aut
将我面向公众的应用程序部署到 Azure。旨在将身份验证委托(delegate)给 Microsoft、Google、Facebook、Apple 等。因此,一旦用户通过其声称的身份验证并且该提供商返
好吧,我对使用 API 的理解有限 我试图掌握 Adobe Sign API 并遇到了死胡同,在测试页面上我输入了这个并且它有效 但我不知道如何在 C# 中做到这一点 我尝试了以下方法,但知道它缺
上下文 我使用 booth Cognito 用户池和 Cognito 身份池来登录用户。 我想完成一个简单的任务,让用户在 iOS 应用程序(Swift 应用程序)上登录。 我的应用程序基于自定义版本
这可能是一个非常简单的答案,但我无法在任何地方找到它。可能是我以某种方式错过了一个非常基本的 CSS 规则。 这是我的 Sass 代码: h3 { font-size: 20px; m
我见过很多将 hex 转换为 int 的问题,但这些都是 unsigned-> unsigned 的变体。如何将带符号的十六进制转换为 Int? 例如。 somefunc('0xfffff830')
我对 C# 中的准备语句有疑问: OdbcCommand cmd = sql.CreateCommand(); cmd.CommandText = "SELECT UNIQUE_ID FROM use
我想知道是否有办法在我发送授权请求之前如果用户是第一次在 Apple 注册我的应用程序,或者他/她是否已经注册,只需登录即可。 基本上我的应用程序中有一个注册屏幕,用户可以在其中创建两种类型的用户和一
我是 Rails 的新手,我正在使用“设计”gem 进行身份验证。 首先,我通过默认注册页面(例如/users/sign_up)添加一个新用户 然后,我按照从 Devise before filter
当我使用 web3.eth.sign() 方法和 web3.eth.accounts.sign() 方法对字符串进行签名时。两个签名的结果值不同。我不知道为什么这两个结果不同。 我正在使用最新的 we
我正在使用受信任的 CA 颁发的证书签署 EXE 程序。 我正在使用 Windows SDK v6.0a 中的 signtool.exe。 该证书位于计算机商店中,位于“个人”文件夹中。 我的命令行是
我是一名优秀的程序员,十分优秀!