在最新的 google play 服务中运行时 Google 登录错误 12500
Posted
技术标签:
【中文标题】在最新的 google play 服务中运行时 Google 登录错误 12500【英文标题】:Google Sign In error 12500 when run in the latest google play services 【发布时间】:2018-06-03 21:12:20 【问题描述】:我正在尝试将 Google Sign In 集成到我的 android 应用程序中,但出现错误。当它运行旧版本的 Google Play 服务(例如 9.8.79)时没有问题,它运行良好。然后当它运行最新版本的Google Play服务时出现问题,错误代码是
StatusstatusCode=unknown status code: 12500, resolution=null
我注意到 logcat 消息是:
12-21 16:47:57.128 909-1861/? W/ActivityManager: Unable to start service Intent act=com.google.android.gms.signin.service.START pkg=com.google.android.gms U=0: not found
12-21 16:47:57.129 909-2225/? W/ActivityManager: Unbind failed: could not find connection for android.os.BinderProxy@daa436e
12-21 16:47:57.129 10959-11128/? E/GmsClient: unable to connect to service: com.google.android.gms.signin.service.START on com.google.android.gms
12-21 16:47:57.133 909-1300/? I/ActivityManager: retrieveServiceLocked, callerApp: ProcessRecord9210179 10959:com.google.android.gms.ui/u0a8, flags: 400
12-21 16:47:57.134 909-1300/? W/ActivityManager: Unable to start service Intent act=com.google.android.gms.signin.service.START pkg=com.google.android.gms U=0: not found
12-21 16:47:57.134 909-1863/? W/ActivityManager: Unbind failed: could not find connection for android.os.BinderProxy@71e6a0f
12-21 16:47:57.135 10959-11128/? E/GmsClient: unable to connect to service: com.google.android.gms.signin.service.START on com.google.android.gms
这可能是什么原因?
谢谢
代码是:
private void googleSignIn()
if(mGoogleApiClient == null)
GoogleSignInOptions gso = new GoogleSignInOptions
.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestId()
.requestIdToken(getResources().getString(R.string.server_client_id))
.build();
mGoogleApiClient = new GoogleApiClient
.Builder(this)
.enableAutoManage(this,this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.enableAutoManage(this, this)/* FragmentActivity *//* OnConnectionFailedListener */
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
if(mGoogleApiClient!=null)
mGoogleApiClient.connect();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
应用分级:
buildscript
repositories
maven url 'https://maven.fabric.io/public'
dependencies
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories
maven url 'https://maven.fabric.io/public'
android
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig
applicationId "com.qraved.imaginato.loginterminator"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
dependencies
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
exclude group: 'com.android.support', module: 'support-annotations'
)
compile 'com.android.support:appcompat-v7:24.1.1'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-auth:9.6.1'
compile('com.twitter.sdk.android:twitter:2.1.1@aar')
transitive = true;
compile 'com.facebook.android:facebook-android-sdk:4.28.0'
项目等级:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
repositories
jcenter()
dependencies
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
allprojects
repositories
jcenter()
task clean(type: Delete)
delete rootProject.buildDir
【问题讨论】:
考虑为你的代码添加一个 sn-p 好的@AndreyF,我会的code:12500
表示用户无法从登录失败中恢复。切换到另一个帐户可能有帮助,也可能没有帮助。
@Wizard 是的,这很头疼,但我必须找到让我的项目工作的理由。唉!
@Wizard 用别的账号不行,而且网络是正常的,当我使用旧版本的谷歌播放服务时,它工作了!
【参考方案1】:
https://developers.google.com/identity/sign-in/android/sign-in 遵循此 api 文档,但请记住,在 WEB_CLIENT_ID 内部使用在 google-services.json 文件中生成的客户端 ID 的值。
class MainActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFailedListener
private val TAG = "JSAGoogleSignIn"
private val REQUEST_CODE_SIGN_IN = 1234
private val WEB_CLIENT_ID = "354298333018-XXXXXXXXXXXXXXXXX.apps.googleusercontent.com"
private var mAuth: FirebaseAuth? = null
private var mGoogleApiClient: GoogleApiClient? = null
override fun onCreate(savedInstanceState: Bundle?)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
var login_button = findViewById<Button>(R.id.button)
var txt_register = findViewById<TextView>(R.id.txt_register)
txt_register.setOnClickListener
var intent = Intent(this@MainActivity, RegisterActivity::class.java)
finish()
startActivity(intent)
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(WEB_CLIENT_ID)
.requestEmail()
.build()
mGoogleApiClient = GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build()
mAuth = FirebaseAuth.getInstance()
sign_in_button.setOnClickListener
val intent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient)
startActivityForResult(intent, REQUEST_CODE_SIGN_IN)
override fun onConnectionFailed(p0: ConnectionResult)
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
private fun updateUI(user: FirebaseUser?)
if (user != null)
Log.e("Email", "Value" + user.email)
override fun onStart()
super.onStart()
val currentUser = mAuth!!.currentUser
updateUI(currentUser)
public override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)
super.onActivityResult(requestCode, resultCode, data)
// Result returned from launching the Intent from GoogleSignInClient.getSignInIntent(...);
if (requestCode == REQUEST_CODE_SIGN_IN)
val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
if (result.isSuccess)
// successful -> authenticate with Firebase
val account = result.signInAccount
firebaseAuthWithGoogle(account!!)
else
// failed -> update UI
updateUI(null)
Toast.makeText(applicationContext, "SignIn: failed!" + result.status,
Toast.LENGTH_SHORT).show()
private fun firebaseAuthWithGoogle(acct: GoogleSignInAccount)
Log.e(TAG, "firebaseAuthWithGoogle():" + acct.id!!)
val credential = GoogleAuthProvider.getCredential(acct.idToken, null)
mAuth!!.signInWithCredential(credential)
.addOnCompleteListener(this) task ->
if (task.isSuccessful)
// Sign in success
Log.e(TAG, "signInWithCredential: Success!")
val user = mAuth!!.currentUser
updateUI(user)
else
// Sign in fails
Log.w(TAG, "signInWithCredential: Failed!", task.exception)
Toast.makeText(applicationContext, "Authentication failed!",
Toast.LENGTH_SHORT).show()
updateUI(null)
private fun handleSignInResult(completedTask: Task<GoogleSignInAccount>)
try
val account = completedTask.getResult(ApiException::class.java)
catch (e: ApiException)
// The ApiException status code indicates the detailed failure reason.
// Please refer to the GoogleSignInStatusCodes class reference for more information.
Log.e("TAG", "signInResult:failed code=" + e.statusCode)
【讨论】:
【参考方案2】:..首先,如果您遇到错误 12500 或 12502 并尝试多次创建新项目并且事情不正常,请冷静下来, 只需检查您的 sha 1 和配置,最重要的是,如果您还添加了 firebase 服务,只需为所有人保留一个项目并检测所有其他项目。 确保您将 sha1 添加到 firebase 控制台项目设置也这是最重要的。
【讨论】:
以上是关于在最新的 google play 服务中运行时 Google 登录错误 12500的主要内容,如果未能解决你的问题,请参考以下文章
用于 Unity 的最新 Google Play 游戏服务插件无法正常工作
如果使用 Google Play 服务,则无法在没有版本冲突的情况下使用最新的 compileSdkVersion 和 targetSdkVersion
使用 Google Play 服务我可以在离线模式下获取最新位置吗(FusedLocationProvider Api)