您可以看到,这是我的代码,大部分是从google文档中复制的,用于google登录身份验证。问题是,当我单击登录按钮时,它向我抛出一个错误“ 16:”,很抱歉张贴图像,我在张贴代码时遇到问题,希望有人能帮助我解决这个问题。
**依赖关系 //对于Firebase
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-crash:15.0.2'
implementation 'com.firebase:firebase-client-android:2.3.1'
implementation 'com.google.firebase:firebase-storage:15.0.2'
implementation 'com.firebaseui:firebase-ui-auth:3.3.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.android.gms:play-services-auth:16.0.0'**
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome_screen);
onCreate();
SignInButton signInButton = findViewById(R.id.sign_in_button);
signInButton.setSize(SignInButton.SIZE_STANDARD);
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
mAuth = FirebaseAuth.getInstance();
signInButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
signIn();
}
});
}
private void signIn() {
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}
private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
try {
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
Intent intent = new Intent(WelcomeScreen.this, Main.class);
startActivity(intent);
} catch (ApiException e) {
Toast.makeText(WelcomeScreen.this, "problem je: " + e.getStatusCode(), Toast.LENGTH_SHORT).show();
}
}
@Override
public void onStart() {
super.onStart();
if (mAuth.getCurrentUser() != null) {
Intent intent = new Intent(WelcomeScreen.this, Main.class);
startActivity(intent);
}
}
@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);
}
}
堆栈跟踪:
2018-09-27 16:32:54.320 6371-6371/com.example.user.graduationproject I/art: Late-enabling -Xcheck:jni
2018-09-27 16:32:54.320 6371-6371/com.example.user.graduationproject D/houdini: [6371] Initialize library(version: 6.1.2d_x.48748 RELEASE)... successfully.
2018-09-27 16:32:54.512 6371-6387/com.example.user.graduationproject W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2018-09-27 16:32:54.540 6371-6391/com.example.user.graduationproject I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:3
2018-09-27 16:32:54.540 6371-6391/com.example.user.graduationproject I/DynamiteModule: Selected remote version of com.google.android.gms.flags, version >= 3
2018-09-27 16:32:54.545 6371-6385/com.example.user.graduationproject D/libEGL: loaded /system/lib/egl/libEGL_adreno.so
2018-09-27 16:32:54.549 6371-6371/com.example.user.graduationproject V/FA: Registered activity lifecycle callback
2018-09-27 16:32:54.550 6371-6391/com.example.user.graduationproject W/System: ClassLoader referenced unknown path:
2018-09-27 16:32:54.558 6371-6391/com.example.user.graduationproject D/ApplicationLoaders: ignored Vulkan layer search path /data/app/com.google.android.gms-1/lib/x86:/data/app/com.google.android.gms-1/base.apk!/lib/x86 for namespace 0xb7684090
2018-09-27 16:32:54.560 6371-6371/com.example.user.graduationproject I/FirebaseInitProvider: FirebaseApp initialization successful
2018-09-27 16:32:54.562 6371-6371/com.example.user.graduationproject I/InstantRun: starting instant run server: is main process
2018-09-27 16:32:54.573 6371-6392/com.example.user.graduationproject W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2018-09-27 16:32:54.575 6371-6385/com.example.user.graduationproject D/libEGL: loaded /system/lib/egl/libGLESv1_CM_adreno.so
2018-09-27 16:32:54.581 6371-6385/com.example.user.graduationproject D/libEGL: loaded /system/lib/egl/libGLESv2_adreno.so
2018-09-27 16:32:54.595 6371-6371/com.example.user.graduationproject W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
2018-09-27 16:32:54.598 6371-6371/com.example.user.graduationproject V/FA: onActivityCreated
2018-09-27 16:32:54.607 6371-6391/com.example.user.graduationproject W/System: ClassLoader referenced unknown path: /data/user_de/0/com.google.android.gms/app_chimera/m/0000000a/n/armeabi-v7a
2018-09-27 16:32:54.607 6371-6391/com.example.user.graduationproject W/System: ClassLoader referenced unknown path: /data/user_de/0/com.google.android.gms/app_chimera/m/0000000a/n/armeabi
2018-09-27 16:32:54.609 6371-6392/com.example.user.graduationproject I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
2018-09-27 16:32:54.609 6371-6392/com.example.user.graduationproject I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
2018-09-27 16:32:54.632 6371-6395/com.example.user.graduationproject V/FA: Collection enabled
2018-09-27 16:32:54.632 6371-6395/com.example.user.graduationproject V/FA: App package, google app id: com.example.user.graduationproject, 1:155824206953:android:24d999f6e00c6563
2018-09-27 16:32:54.632 6371-6395/com.example.user.graduationproject I/FA: App measurement is starting up, version: 12451
2018-09-27 16:32:54.632 6371-6395/com.example.user.graduationproject I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
2018-09-27 16:32:54.632 6371-6395/com.example.user.graduationproject I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.example.user.graduationproject
2018-09-27 16:32:54.632 6371-6395/com.example.user.graduationproject D/FA: Debug-level message logging enabled
2018-09-27 16:32:54.635 6371-6391/com.example.user.graduationproject W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
2018-09-27 16:32:54.637 6371-6391/com.example.user.graduationproject I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:215
2018-09-27 16:32:54.637 6371-6391/com.example.user.graduationproject I/DynamiteModule: Selected remote version of com.google.android.gms.crash, version >= 215
2018-09-27 16:32:54.640 6371-6391/com.example.user.graduationproject I/FirebaseCrashApiImpl: FirebaseCrashApiImpl created by ClassLoader ad[DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/0000000a/DynamiteModulesC.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/0000000a/n/armeabi-v7a, /data/user_de/0/com.google.android.gms/app_chimera/m/0000000a/n/armeabi, /system/lib, /vendor/lib]]]
2018-09-27 16:32:54.641 6371-6391/com.example.user.graduationproject I/FirebaseCrash: FirebaseCrash reporting loaded - com.google.android.gms.internal.measurement.zzxw@9bbbe64
2018-09-27 16:32:54.648 6371-6393/com.example.user.graduationproject I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:3
2018-09-27 16:32:54.648 6371-6393/com.example.user.graduationproject I/DynamiteModule: Selected remote version of com.google.android.gms.flags, version >= 3
2018-09-27 16:32:54.652 6371-6393/com.example.user.graduationproject W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
2018-09-27 16:32:54.662 6371-6393/com.example.user.graduationproject I/FirebaseCrashApiImpl: FirebaseCrash reporting API initialized
2018-09-27 16:32:54.662 6371-6393/com.example.user.graduationproject I/FirebaseCrash: FirebaseCrash reporting initialized com.google.android.gms.internal.measurement.zzxw@9bbbe64
2018-09-27 16:32:54.662 6371-6393/com.example.user.graduationproject D/FirebaseCrash: Firebase Analytics Listener for Firebase Crash is initialized
2018-09-27 16:32:54.666 6371-6395/com.example.user.graduationproject V/FA: Cancelling job. JobID: -1494669227
2018-09-27 16:32:54.676 6371-6395/com.example.user.graduationproject V/FA: Connecting to remote service
2018-09-27 16:32:54.680 6371-6395/com.example.user.graduationproject V/FA: Connection attempt already in progress
2018-09-27 16:32:55.250 6371-6371/com.example.user.graduationproject D/ApplicationLoaders: ignored Vulkan layer search path /data/app/com.google.android.gms-1/lib/x86:/data/app/com.google.android.gms-1/base.apk!/lib/x86 for namespace 0xb76840d0
2018-09-27 16:32:55.256 6371-6371/com.example.user.graduationproject I/DynamiteModule: Considering local module com.google.android.gms.signinbutton_dynamite:0 and remote module com.google.android.gms.signinbutton_dynamite:2
2018-09-27 16:32:55.256 6371-6371/com.example.user.graduationproject I/DynamiteModule: Selected remote version of com.google.android.gms.signinbutton_dynamite, version >= 2
2018-09-27 16:32:55.274 6371-6371/com.example.user.graduationproject W/System: ClassLoader referenced unknown path: /data/user_de/0/com.google.android.gms/app_chimera/m/00000009/n/armeabi-v7a
2018-09-27 16:32:55.274 6371-6371/com.example.user.graduationproject W/System: ClassLoader referenced unknown path: /data/user_de/0/com.google.android.gms/app_chimera/m/00000009/n/armeabi
2018-09-27 16:32:55.323 6371-6395/com.example.user.graduationproject I/FA: Tag Manager is not found and thus will not be used
2018-09-27 16:32:55.335 6371-6395/com.example.user.graduationproject D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=WelcomeScreen, firebase_screen_id(_si)=-4609609622484588595}]
2018-09-27 16:32:55.350 6371-6395/com.example.user.graduationproject V/FA: Connection attempt already in progress
2018-09-27 16:32:55.351 6371-6395/com.example.user.graduationproject V/FA: Connection attempt already in progress
2018-09-27 16:32:55.351 6371-6395/com.example.user.graduationproject V/FA: Activity resumed, time: 2956494
2018-09-27 16:32:55.363 6371-6399/com.example.user.graduationproject I/OpenGLRenderer: Initialized EGL, version 1.4
2018-09-27 16:32:55.363 6371-6399/com.example.user.graduationproject D/OpenGLRenderer: Swap behavior 1
2018-09-27 16:32:55.413 6371-6399/com.example.user.graduationproject W/EGL_emulation: eglSurfaceAttrib not implemented 3093 12436
2018-09-27 16:32:55.413 6371-6399/com.example.user.graduationproject W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa9078e80, error=EGL_SUCCESS
2018-09-27 16:32:55.420 6371-6371/com.example.user.graduationproject W/art: Before Android 4.1, method int android.support.v7.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
2018-09-27 16:32:55.460 6371-6395/com.example.user.graduationproject D/FA: Connected to remote service
2018-09-27 16:32:55.461 6371-6395/com.example.user.graduationproject V/FA: Processing queued up service tasks: 4
2018-09-27 16:32:57.221 6371-6395/com.example.user.graduationproject V/FA: Recording user engagement, ms: 1898
2018-09-27 16:32:57.222 6371-6395/com.example.user.graduationproject V/FA: Activity paused, time: 2958392
2018-09-27 16:32:57.224 6371-6395/com.example.user.graduationproject D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=1898, firebase_screen_class(_sc)=WelcomeScreen, firebase_screen_id(_si)=-4609609622484588595}]
2018-09-27 16:32:57.231 6371-6371/com.example.user.graduationproject V/FA: onActivityCreated
2018-09-27 16:32:57.241 6371-6395/com.example.user.graduationproject D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=WelcomeScreen, firebase_previous_id(_pi)=-4609609622484588595, firebase_screen_class(_sc)=SignInHubActivity, firebase_screen_id(_si)=-4609609622484588594}]
2018-09-27 16:32:57.268 6371-6395/com.example.user.graduationproject V/FA: Activity resumed, time: 2958410
2018-09-27 16:32:57.269 6371-6395/com.example.user.graduationproject V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 31
2018-09-27 16:32:57.273 6371-6395/com.example.user.graduationproject V/FA: Activity paused, time: 2958411
2018-09-27 16:32:57.287 6371-6399/com.example.user.graduationproject W/EGL_emulation: eglSurfaceAttrib not implemented 3093 12436
2018-09-27 16:32:57.287 6371-6399/com.example.user.graduationproject W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb2d390c0, error=EGL_SUCCESS
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: com.google.android.gms.common.api.ApiException: 16:
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at com.example.user.graduationproject.Bjelasnica.WelcomeScreen.onActivityResult(WelcomeScreen.java:88)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at android.app.Activity.dispatchActivityResult(Activity.java:6945)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at android.app.ActivityThread.deliverResults(ActivityThread.java:4088)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at android.app.ActivityThread.handleSendResult(ActivityThread.java:4135)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at android.app.ActivityThread.-wrap20(ActivityThread.java)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1536)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at android.os.Looper.loop(Looper.java:154)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6169)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
2018-09-27 16:33:01.904 6371-6371/com.example.user.graduationproject W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
2018-09-27 16:33:01.910 6371-6395/com.example.user.graduationproject D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=SignInHubActivity, firebase_previous_id(_pi)=-4609609622484588594, firebase_screen_class(_sc)=WelcomeScreen, firebase_screen_id(_si)=-4609609622484588595}]
2018-09-27 16:33:01.936 6371-6395/com.example.user.graduationproject V/FA: Activity resumed, time: 2963077
2018-09-27 16:33:01.953 6371-6399/com.example.user.graduationproject W/EGL_emulation: eglSurfaceAttrib not implemented 3093 12436
2018-09-27 16:33:01.953 6371-6399/com.example.user.graduationproject W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xb2d390c0, error=EGL_SUCCESS
2018-09-27 16:33:04.784 6371-6426/com.example.user.graduationproject I/FirebaseCrash: Sending crashes
2018-09-27 16:33:06.937 6371-6395/com.example.user.graduationproject V/FA: Inactivity, disconnecting from the service
答案 0 :(得分:4)
我有同样的问题。这是我的解决方案。希望你能理解。
情况:当错误代码为“ 16:”,并停留在“使用Google登录”时,如何解决此问题,当我们在消息框中按我们的电子邮件后,没有出现下一个活动,而仅出现了错误。
5.2。要解决这个问题:
5.2.1。从您的项目(Android Studio)中获取SHA1
5.2.2。创建API密钥和OAuth 2.0客户端ID(Android类型)。 (https://console.cloud.google.com/apis/credentials)
5.2.3。因此,数据是在Google上设置的,因此请在https://console.firebase.google.com/(在“项目设置”中)获得新的Firebase控制台google.json。下载并替换。
5.2.4。关闭Android Studio,重新打开,然后“制作项目”
5.2.5。在电话上运行。成功!
请参阅此链接:google signIn not working in release mode apk android
有关Google API的其他信息:https://developers.google.com/maps/documentation/android-sdk/config (为manifest.xml添加额外的内容)
答案 1 :(得分:0)
将Android上的Google SignIn与Firebase集成时,我还看到“错误代码16”。仍然不确定我丢失了什么,但是我回到了开始并遵循了这个文档:
https://firebase.google.com/docs/auth/android/google-signin
此链接非常完整。我不需要在Google Cloud Console中进行任何配置。我确实使用了上面页面链接到的Integrating Google SignIn页面上的信息,并获得了按钮的代码和布局。