Rahul Patil Rahul Patil - 1 year ago 116
Android Question

Android Google Login sign in error , android build system

I have Google login feature in our application . And we are building apk from build system use "mm" or "make" command , I have included required necessary jar's for google login in Android.mk.

Now my problem is I am unable to login using Google if I require oauth token error returned is statusCode=unknown status code: 12501, resolution=null

String serverClientId = getString(R.string.server_client_id);

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(

// Build a GoogleApiClient with access to the Google Sign-In API and the
// options specified by gso.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso).build();

where serverClientId is webapplication id returned after google developer console

I am using above code. If I use Scope I am able to login successfully but no oauth token.

If I use same code and run in Android Studio I am able to login as it has google_service.json file so gradle picks up and builds apk.

So in my case have any one tried google sign-in by building apk from build system , my assumption is we need to link google service json file to Android.mk

Answer Source

After three days I got the solution for answer. Why it was working with Android Studio is , apk will get signed with debug key while building . Where as from the build system it is not signed with debug key . So what I am doing now is sign the apk with debug keystore after it is generated after "mm" command. We need to use MD5(SHA1) in Google account as well.

1. zip -d <APK> "META-INF*"
2. jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore <path to keystore>/debug.keystore <APK> keyalas
3. <path to zipalign>/zipalign -v 4 <APK in> <APK out>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download