1

Hi I have a android project where it reads certain data from application user's Google Fit profile. I faced a weird scenario as below. all the below are in debug mode and not in release mode.

1) when compiled from my own laptop oAuth successfully worked on my phone and workflow is working fine.

2) when same code is compiled from another developer's machine, after selecting the account to be used, it does not show the permission page where we need to grant permission to google fit and the protected void onActivityResult(int requestCode, int resultCode, Intent data) method is called with result code of "RESULT_CANCELED". tried numerous times with same results

3) I plugged the same phone from my laptop and pushed the same code. this time it showed the permission page in his phone and once approved, complete flow works fine.

4) then we uninstalled the app and pushed the apk compiled from the other dev's laptop and now the OAuth works fine and flow is working without issue because the permission is already granted on the google profile for the application.

the issue seems weird and any direction to solving would be appreciated.

  • 1
    Based from this [thread](http://stackoverflow.com/questions/37289028/google-oauth-2-0-result-canceled-while-using-google-fit-api), you can get `RESULT_CANCELED` if your package name is diferent than the one you define in your app. Check if you are not setting another `AppID` in your `build.gradle` that could be different with the package name defined in your manifest. You may also check this related [question](http://stackoverflow.com/questions/28154332/android-google-fit-onconnectionfailed-sign-in-required). – abielita May 30 '16 at 09:54
  • Thnx for the help. in our case it was not using same key store for debug builds caused this problem. release build was working fine and once we integrated common keystore and register it with dev console issue get resolved. added as an answer if someone needs the help in future. – Amila Banuka Amarasinghe Jun 02 '16 at 08:52

1 Answers1

4

It seems the reason for this issue in our case is Incorrect keystores. for debug we did not used common keystores across every one and once we used one key store and register it in developer console this issue was resolved.

  • 1
    Thanks for your findings. After spending a lot of hours, I was finally able to figure out the actual issue. One thing I would like to point out for others is that, this can happen with you on your own machine if the `keystore` is different for your `debug` and `release` build. I faced that issue. After doing all the set up correctly, you need to remember that **oauth** token is being generated using your keystore file. But **Android Studio** uses a `debug.keystore` file for all the debug builds. You need to change that in your `signing` configurations and set up will work like charm. :) – Abhishek Sep 25 '18 at 07:00
  • @Abhishek I am facing same issue. My SHA1 is registered on the google account still having authentication issue with the debug apk. Can you please elaborate about your last line what I need to change in signing configurations ? – Shriya Pandya Mar 30 '22 at 11:25
  • @ShriyaPandya what I meant is if you change your build variant to release then the authentication should work. However, if you want to test with you debug build, then you need to register your debug keystore to your google account or use the relese keystore to sign your debug builds. Hope it helps :) – Abhishek Mar 30 '22 at 18:02
  • @Abhishek Thanks a lot for you response. I have used release keystore to sign in debug build then apk is not getting installed. Error is "App not installed". – Shriya Pandya Mar 31 '22 at 10:17
  • 1
    @Abhishek Issue has been resolved by accessing debug.keystore's SHA1 like this -list -v -keystore PATH/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android Crated new entry with this SHA1 on google auth client 2.0 . – Shriya Pandya Mar 31 '22 at 11:06