Google signs a signed apk not working

Well, everything works until I generated a signed apk. I completed the whole process as stated on the Google Developers page

1.I created a google-services.json file with the key and package name in it
2. Include all level-level and application-level dependencies like this.

// 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:1.3.0' classpath 'com.google.gms:google-services:2.0.0-alpha6' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } } 

Gradle file application

 apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 23 buildToolsVersion "23.0.0" defaultConfig { applicationId "com.example.skmishra.finalgooglesignin" minSdkVersion 14 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.google.android.gms:play-services:8.3.0' } 
  1. My java code

     package com.example.skmishra.finalgooglesignin; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.Toast; import com.google.android.gms.auth.api.Auth; import com.google.android.gms.auth.api.signin.GoogleSignInAccount; import com.google.android.gms.auth.api.signin.GoogleSignInOptions; import com.google.android.gms.auth.api.signin.GoogleSignInResult; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.SignInButton; import com.google.android.gms.common.api.GoogleApiClient; public class MainActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener, View.OnClickListener { private static final int RC_SIGN_IN = 200 ; private static final String TAG = "Sign In" ; private GoogleApiClient mGoogleApiClient; SignInButton google; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Configure sign-in to request the user ID, email address, and basic // profile. ID and basic profile are included in DEFAULT_SIGN_IN. GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestEmail() .build(); mGoogleApiClient = new GoogleApiClient.Builder(this) .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */) .addApi(Auth.GOOGLE_SIGN_IN_API, gso) .build(); SignInButton signInButton = (SignInButton) findViewById(R.id.sign_in_button); signInButton.setSize(SignInButton.SIZE_STANDARD); signInButton.setScopes(gso.getScopeArray()); google=(SignInButton)findViewById(R.id.sign_in_button); google.setOnClickListener(this); } @Override public void onConnectionFailed(ConnectionResult connectionResult) { Toast.makeText(this,"Failed to connect",Toast.LENGTH_LONG).show(); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.sign_in_button: signIn(); break; // ... } } private void signIn() { Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient); startActivityForResult(signInIntent, RC_SIGN_IN); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...); if (requestCode == RC_SIGN_IN) { GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data); handleSignInResult(result); } } private void handleSignInResult(GoogleSignInResult result) { Log.d(TAG, "handleSignInResult:" + result.isSuccess()); if (result.isSuccess()) { // Signed in successfully, show authenticated UI. GoogleSignInAccount acct = result.getSignInAccount(); Toast.makeText(this,"Name :"+acct.getDisplayName()+" Email :"+acct.getEmail(),Toast.LENGTH_LONG).show(); } else { // Signed out, show unauthenticated UI. Toast.makeText(this,"Signed out ",Toast.LENGTH_LONG).show(); } } } 
    1. My layout code

        <com.google.android.gms.common.SignInButton android:id="@+id/sign_in_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Check this out" /> 
+5
source share
5 answers

As I understand it, you provided debug SHA1 in the developer console, then you signed apk and SHA1 changed. If so, try the following: get the SHA1 release from the keystore and replace the old SHA with this.

1. Open a terminal and change the directory to the JDK bin directory. Include the installed JDK version inside the path, for me it was jdk1.8.0_101 (type javac -version to get the Java version):

Mac

  cd /Library/Java/JavaVirtualMachines/<your_JDK_version>.jdk/Contents/Home/bin 

Window

  cd C:\Program Files\Java\your_JDK_version\bin 

2. Use keytool to get SHA1 release:

  keytool -list -v -keystore <keystore_name> -alias <alias_name> 

3. Go to the project credentials page and replace SHA1 with your SHA1 repository release.

+10
source

I had the same problem. I think I found out that Google does not allow you to have one certificate for both debugging and apk of your application. You need to choose or get a certificate for only one of them. Please correct me if I am wrong.

What I did was enter the SHA1 fingerprint credentials for my release , not my debug key at this link here

Subsequently, my released apk worked, not my debug key.

+3
source

It's hard to find a place to activate inside the huge developer console. Maybe I will help someone in the future. You must register your Android application here - β€œenable login” on this page :

Just enter the usual console developer value for this signed SHA-1. What is it!

0
source

@ - vj- @ ==> The API key is based on the short form of your digital application certificate, known as its SHA-1 fingerprint. To display the SHA-1 fingerprint for your certificate, first make sure that you are using the correct certificate. You can have two certificates:

-> Debug certificate: Android SDK tools automatically generate this certificate when you build debugging. Use this certificate only with applications that you are testing. Do not try to publish an application signed with a debug certificate. The debug certificate is described in more detail in the "Signing in Debug Mode" section of the Android developer documentation.

-> Release Certificate: Android SDK tools generate this certificate when creating the release. You can also generate this certificate using keytool. Use this certificate when you are ready to release the application into the world.

==> Display debug certificate fingerprint

Locate the debug repository file. The file name is debug.keystore and is created when the project is first created. By default, it is stored in the same directory as the Android Virtual Device (AVD) files:

macOS and Linux: ~/.android/ Windows Vista and Windows 7: C:\Users\your_user_name\.android\ List the SHA-1 fingerprint:

For Linux or macOS, open a terminal window and enter the following:

 keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 

For Windows Vista and Windows 7, run:

 keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android 

==> Display the fingerprint of the certificate of issue

Locate the release key store file. There is no default location or name for the release key store. If you do not specify when you will create the application for release, the assembly will leave your .apk unsigned and you will have to sign it before you can publish it. For a certificate of issue, you also need a certificate alias and passwords for the keystore and certificate. You can list the aliases for all keys in the keystore by entering:

 keytool -list -keystore your_keystore_name 

Replace your_keystore_name with the full path and name of the keystore, including the .keystore extension. You will be prompted for a keystore password. Keytool then displays all the aliases in the keystore. At the command prompt, enter the following command:

 keytool -list -v -keystore your_keystore_name -alias your_alias_name 

Replace your_keystore_name with the full path and name of the keystore, including the .keystore extension. Replace your_alias_name alias you assigned to the certificate when you created it.

0
source

FWIW:

For me, I had a release and debug configuration (OAT client identifiers, SHA-1, etc.) configured in the Google dev console and the google-services.json file installed in the project.

Since I work with several build options, I put the various configuration files in the corresponding ./app/<flavorN>/ directories.

My error did not generate a signed APK with the correct keystore file, alias, and password in the Create Signed APK wizard. The wizard cached keys and credentials from a previous build style (tsk). But after reinstalling the keys to match the target taste, I now have a valid Google login.

0
source

Source: https://habr.com/ru/post/1245187/


All Articles