Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
143 views
in Technique[技术] by (71.8m points)

android - ClassNotFoundException for SignInConfiguration when signing in with Google

I'm implementing Google login to an app. The login itself seems to work okay, but the moment I request either the user's e-mail or ID token I see the following stack trace in the log and the status from GoogleSignInResult as Status{statusCode=unknown status code: 12500, resolution=null}

03-30 13:59:09.821 3634-4322/? E/Parcel: Class not found when unmarshalling: com.google.android.gms.auth.api.signin.internal.SignInConfiguration
                                         java.lang.ClassNotFoundException: com.google.android.gms.auth.api.signin.internal.SignInConfiguration
                                             at java.lang.Class.classForName(Native Method)
                                             at java.lang.Class.forName(Class.java:309)
                                             at java.lang.Class.forName(Class.java:273)
                                             at android.os.Parcel.readParcelableCreator(Parcel.java:2281)
                                             at android.os.Parcel.readParcelable(Parcel.java:2245)
                                             at android.os.Parcel.readValue(Parcel.java:2152)
                                             at android.os.Parcel.readArrayMapInternal(Parcel.java:2485)
                                             at android.os.BaseBundle.unparcel(BaseBundle.java:221)
                                             at android.os.BaseBundle.getString(BaseBundle.java:918)
                                             at android.content.Intent.getStringExtra(Intent.java:5767)
                                             at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:2365)
                                             at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1848)
                                             at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5809)
                                             at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:5593)
                                             at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:142)
                                             at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3786)
                                             at android.os.Binder.execTransact(Binder.java:461)
                                          Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.api.signin.internal.SignInConfiguration" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
                                             at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                             at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                             at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                             at java.lang.Class.classForName(Native Method)?
                                             at java.lang.Class.forName(Class.java:309)?
                                             at java.lang.Class.forName(Class.java:273)?
                                             at android.os.Parcel.readParcelableCreator(Parcel.java:2281)?
                                             at android.os.Parcel.readParcelable(Parcel.java:2245)?
                                             at android.os.Parcel.readValue(Parcel.java:2152)?
                                             at android.os.Parcel.readArrayMapInternal(Parcel.java:2485)?
                                             at android.os.BaseBundle.unparcel(BaseBundle.java:221)?
                                             at android.os.BaseBundle.getString(BaseBundle.java:918)?
                                             at android.content.Intent.getStringExtra(Intent.java:5767)?
                                             at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:2365)?
                                             at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1848)?
                                             at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5809)?
                                             at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:5593)?
                                             at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:142)?
                                             at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3786)?
                                             at android.os.Binder.execTransact(Binder.java:461)?
                                            Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.auth.api.signin.internal.SignInConfiguration
                                             at java.lang.Class.classForName(Native Method)
                                             at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                             at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                             at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                    ... 18 more
                                          Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

This is the code I'm using for trying to log in the user:

public class SignInActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener {

    private final static String TAG = SignInActivity.class.getSimpleName();

    protected final static int REQUEST_CODE_GOOGLE_LOGIN = 1;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sign_in);

        GoogleSignInOptions googleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
//                .requestEmail() // Causes ClassNotFoundException for SignInConfiguration
//                .requestIdToken(getString(R.string.google_server_client_id)) // Causes ClassNotFoundException for SignInConfiguration
                .build();
        final GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this, this)
                .addApi(Auth.GOOGLE_SIGN_IN_API, googleSignInOptions)
                .build();

        SignInButton signInButton = (SignInButton) findViewById(R.id.signInButton);
        signInButton.setScopes(googleSignInOptions.getScopeArray());
        signInButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient);
                startActivityForResult(signInIntent, REQUEST_CODE_GOOGLE_LOGIN);
            }
        });

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_CODE_GOOGLE_LOGIN) {
            GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
            handleGoogleSignInResult(result);
        }
    }

    protected void handleGoogleSignInResult(GoogleSignInResult googleSignInResult) {
        Logging.debug(TAG, "handleGoogleSignInResult(" + googleSignInResult + ")");
        if (googleSignInResult.isSuccess()) {
            GoogleSignInAccount googleSignInAccount = googleSignInResult.getSignInAccount();
            final String idToken = googleSignInAccount.getIdToken();
            if (idToken != null) {
                Toast.makeText(SignInActivity.this, "Successfully logged in.", Toast.LENGTH_SHORT).show();
                // Do fun stuff here
            } else {
                Log.e(TAG, "ID token was null. Unable to sign in user.");
            }
        } else {
            Log.e(TAG, "Failed to sign in with Google. Status:" + googleSignInResult.getStatus());
        }
    }

    @Override
    public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
        Log.e(TAG, "onConnectionFailed(" + connectionResult + ")");
    }

}

What am I doing wrong?

I'm using the following gradle dependency:

compile 'com.google.android.gms:play-services-auth:8.4.0'

The logged exception seems to come from another process. I've even tried to instanciate com.google.android.gms.auth.api.signin.internal.SignInConfiguration my Activity to be sure that I have the class accessible.

This is happening on the debug build which doesn't use proguard.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think this might be a red-herring. I had the exact same stack trace and have spent a ton of time trying to determine the cause. I came across a similar post while researching which indicated it might be a Samsung only exception that could be ignore (them inspecting intents in transit or something). Sure enough, I tried on an HTCOne device and the exception no longer appeared. I still had the same overall Google Auth problems, but at least I could move on to the real issue which (for me at least) appears to be SHA/Cert/Account/Signing related. Anyway - hope this helps (something to check on anyway)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...