4

I have a Android/IOS app build with cordova.

As I'm running the server with ssl now, I can't open with the inappBrowser the requests from google. So I have to use the native login, with this plugin. ( Which is the most reliable that I have found )

After reading many posts ( this, this, and .. ) I believe that the problem it's in the way I am (trying to) generate my key file

keytool -exportcert -keystore ~/.android/debug.keystore -list -v -alias myAppName

(with empty password ) it prompts

error de herramienta de claves: java.lang.Exception: El alias <myAppName> no existe (doesn't exist)
java.lang.Exception: El alias <myAppName> no existe
    at sun.security.tools.keytool.Main.doPrintEntry(Main.java:1738)
    at sun.security.tools.keytool.Main.doCommands(Main.java:1064)
    at sun.security.tools.keytool.Main.run(Main.java:343)
    at sun.security.tools.keytool.Main.main(Main.java:336)

Does that mean it didn't work?

About the error:

window.plugins.googleplus.login(
    {
      'scopes': 'profile email', 
      'webClientId': 'xxxxxxxxx.apps.googleusercontent.com', 
      'offline': true, 
    },
    function (obj) {
      alert(JSON.stringify(obj)); /
    },
    function (msg) {
      alert('error: ' + msg); // <--- It alerts 'error: 10'
    }
);

enter image description here

Any hint would be very welcome

-EDIT (this is now solved)-

Just tested in IOS (simulator) and the result is even worse: enter image description here

-EDIT 2-

I tried to install it both ways ( same result )

  • cordova plugin add cordova-plugin-googleplus --save --variable REVERSED_CLIENT_ID=myreversedclientid
  • cordova plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --save --variable REVERSED_CLIENT_ID=myreversedclientid

( And multiple times, before and after "setting" the .key )

-EDIT 3-

BTW, What does this error mean? ( can't find it, either )

Toni Michel Caubet
  • 19,333
  • 56
  • 202
  • 378
  • This issue (https://github.com/EddyVerbruggen/cordova-plugin-googleplus/issues/243) provides many different solutions (which seem to work for all of the users) for that problem. Have you tried all of them? – David Sep 11 '17 at 17:15
  • I read that one, too. It links to a solution. But my problem is that its not working even in development. I think my problem is the way I'm generating my certs.. – Toni Michel Caubet Sep 12 '17 at 08:23
  • Check if your debug.keystore is in the default directory (assuming you are working on a mac): https://stackoverflow.com/a/7529858/6184203 – David Sep 12 '17 at 11:36
  • Thanks! yes, it's in: `/Users/toni/.android/debug.keystore` – Toni Michel Caubet Sep 12 '17 at 12:42
  • Then continue reading here: https://stackoverflow.com/questions/6925659/keytool-alias-does-not-exist – David Sep 12 '17 at 12:51
  • Sorry, the same info there.. Do you mean that I should use a different path or.. ? – Toni Michel Caubet Sep 12 '17 at 13:01
  • Yes you should try a few different things. There are so many answers on this topic. – David Sep 12 '17 at 13:04
  • @David i know.. i might have read them all... I think this article linked in the first URL you commented has the answers. But I can't find those pages in the google console.. ( already asked the author but still waiting for reply.. ) – Toni Michel Caubet Sep 12 '17 at 13:06
  • This page: https://console.developers.google.com/apis/credentials or the App-signing page in the developer console? – David Sep 12 '17 at 13:41
  • please post your `GoogleService-Info.plist`. Also in my project I don't use `'scopes': 'profile email', ` – Maxim Shoustin Sep 15 '17 at 10:17
  • @MaximShoustin Thanks for writing. I don't seem to find a `GoogleService-Info.plist` file. In which folder should it be? – Toni Michel Caubet Sep 15 '17 at 12:32

2 Answers2

8

For me error 10 happened when the generated SHA1 by keytool(which i used to add the app to google) mismatched with the build apk's sha 1. How i fixed is by editing the SHA1 of the google project to the build apks SHA1.

1 - first, build the apk

cordova build android --device --verbose --stacktrace --debug

2 - see path to your apk. it will be in projectfolder/platforms/outputs/apk/android-debug.apk

3 - get the SHA1 of the apk

keytool -list -printcert -jarfile <path to your apk>

it will output the details which include SHA1. copy this and replace the SHA1 in google project app.

4 - go to firebase console open app edit the SHA1. copy the build apk's SHA1 to replace the previous SHA1 which we initially pasted on when creating the app.

aimme
  • 6,385
  • 7
  • 48
  • 65
1

I don't seem to find a GoogleService-Info.plist file. In which folder should it be?

Since we talk about iOS I believe GoogleService-Info.plist file is missing and this is a problem. Please take a look on this EddyVerbruggen/cordova-plugin-googleplus

To get your iOS REVERSED_CLIENT_ID, generate a configuration file here. This GoogleService-Info.plist file contains the REVERSED_CLIENT_ID you'll need during installation. This value is only needed for iOS.

The REVERSED_CLIENT_ID is also known as the "iOS URL Scheme" on the Developer's Console.

Login on iOS takes the user to a SafariViewController through the Google SDK, instead of the separate Safari browser.

To generate a configuration file go to: https://developers.google.com/mobile/add?platform=ios

Locate this file in root of your iOS project


In my case the GoogleService-Info.plist file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CLIENT_ID</key>
    <string>18643434937-j6ofvkktk1uklqjv61ecr75f1llqki0f.apps.googleusercontent.com</string>
    <key>REVERSED_CLIENT_ID</key>
    <string>com.googleusercontent.apps.18643434937-j6ofvkktk1uklqjv61ecr75f1llqki0f</string>
    <key>PLIST_VERSION</key>
    <string>1</string>
    <key>BUNDLE_ID</key>
    <string>com.app.client</string>
    <key>PROJECT_ID</key>
    <string>app-c6c82</string>
    <key>IS_ADS_ENABLED</key>
    <false/>
    <key>IS_ANALYTICS_ENABLED</key>
    <false/>
    <key>IS_APPINVITE_ENABLED</key>
    <false/>
    <key>IS_GCM_ENABLED</key>
    <false/>
    <key>IS_SIGNIN_ENABLED</key>
    <true/>
    <key>GOOGLE_APP_ID</key>
    <string>1:68743434937:ios:b03bcd3b3f571a56</string>
</dict>
</plist>

For Android google-services.json:

Go to: https://developers.google.com/mobile/add?platform=android

and generate it there.

It should look like:

{
  "project_info": {
    "project_number": "68643434935",
    "project_id": "myapp-c6c82"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:68643434935:android:71bc3a4035ab9002",
        "android_client_info": {
          "package_name": "com.agan.armoa"
        }
      },
      "oauth_client": [
        {
          "client_id": "68643434935-mqm5s8lubfr5j5s3bj62eigbod0h083s.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "com.agan.armoa",
            "certificate_hash": "759A66458E30A70628F2E6A66C46240E21676B72"
          }
        },
        {
          "client_id": "68643434935-bc48465luu0r77tufpf4fumv0bd5pta2.apps.googleusercontent.com",
          "client_type": 3
        },
        {
          "client_id": "68643434935-gpdj67581deilm3refkgobuvneceisqt.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "AIzaSyDB6g1-nMbZ9aZkic2dCz8QrcqHfCSDrsw"
        }
      ],
      "services": {
        "analytics_service": {
          "status": 1
        },
        "appinvite_service": {
          "status": 1,
          "other_platform_oauth_client": []
        },
        "ads_service": {
          "status": 1
        }
      }
    },
    {
      "client_info": {
        "mobilesdk_app_id": "1:68643434935:android:b03bcd3b3f571a56",
        "android_client_info": {
          "package_name": "com.myapp.client"
        }
      },
      "oauth_client": [
        {
          "client_id": "68643434935-25ciu2gccfv70m08sc7c4fr3v0gqe89m.apps.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "com.myapp.client",
            "certificate_hash": "E90A75A9AA4470337AE5ECD87C3416DDB1109BE1"
          }
        },
        {
          "client_id": "68643434935-bc48465luu0r77tufpf4fumv0bd5pta2.apps.googleusercontent.com",
          "client_type": 3
        },
        {
          "client_id": "68643434935-gpdj67581deilm3refkgobuvneceisqt.apps.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "AIzaSyDB6g1-nMbZ9aZkic2dCz8QrcqHfCSDrsw"
        }
      ],
      "services": {
        "analytics_service": {
          "status": 1
        },
        "appinvite_service": {
          "status": 1,
          "other_platform_oauth_client": []
        },
        "ads_service": {
          "status": 1
        }
      }
    }
  ],
  "configuration_version": "1"
}

[EDIT 2]

About your error:

keytool -exportcert -list -v \ -alias project -keystore ~/.android/debug.keystore I get this error: error de herramienta de claves: java.lang.Exception: El archivo de almacén de claves no existe: /Users/toni/.android/debug.keystore java.lang.Exception: El archivo de almacén de claves no existe: /Users/toni/.android/debug.keystore

Try to run:

keytool -genkey -v -keystore ~/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"

to generate ~/.android/debug.keystore

Also take a look: https://developer.android.com/studio/publish/index.html#debugmode

[EDIT 3]

error 10 means:

public static final int DEVELOPER_ERROR

The application is misconfigured. This error is not recoverable and will be treated as fatal. The developer should look at the logs after this to determine more actionable information.

Constant Value: 10

See DOCS and similar error solution: Error: Status{statusCode=DEVELOPER_ERROR, resolution=null}

Community
  • 1
  • 1
Maxim Shoustin
  • 77,483
  • 27
  • 203
  • 225
  • Thank you for your answer, the thing is that it generated different id/reverse_id than I use in the website. is that a problem? also, in which folder of the cordova project should I place the file? – Toni Michel Caubet Sep 17 '17 at 18:36
  • You should use what is generated. The file should be located under `PROGECT_ROOT/platforms/ios//` in my case its `~/projects/moodo/platforms/ios/Moodo/GoogleService-Info.plist` (next to `Classes`) – Maxim Shoustin Sep 17 '17 at 18:43
  • Generally you register ios app on Google Console – Maxim Shoustin Sep 17 '17 at 18:43
  • After saving the GoogleService-Info.plist in the project path under `platforms/ios/project` it's working in IOS! So thanks for that! :D but same error ( error 10 ) in Android.. any clue about the android 10 error? – Toni Michel Caubet Sep 18 '17 at 08:53
  • @ToniMichelCaubet do you have `google-services.json` file inside Android Project? – Maxim Shoustin Sep 18 '17 at 09:26
  • No, should it look like this? ( just downloaded from the google credentials page) `{"web":{"client_id":"xxxxxx.apps.googleusercontent.com","project_id":"api-project-xxxxxx","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"nyK_io3qRNK_OgOcEceKTLC4","redirect_uris":["https://project.com/google.php","http://project.com/google.php","https://beta.project.com/google.php"],"javascript_origins":["https://project.com","https://beta.project.com"]}}` – Toni Michel Caubet Sep 18 '17 at 09:49
  • If you checkout my original question I had trouble generating/setting/dunnoWhat my keys: when I type: `keytool -exportcert -list -v \ -alias project -keystore ~/.android/debug.keystore` I get this error: `error de herramienta de claves: java.lang.Exception: El archivo de almacén de claves no existe: /Users/toni/.android/debug.keystore java.lang.Exception: El archivo de almacén de claves no existe: /Users/toni/.android/debug.keystore` ( in english mean that they key is not found ) very frustrating.. – Toni Michel Caubet Sep 18 '17 at 10:53
  • Thanks for your last edit. I was able to generate de debug.keystore and entered in the google certificate page. Downloaded de json file and placed into `/platforms/android` tried to run the app in device. Still got `error 10` :( – Toni Michel Caubet Sep 18 '17 at 11:12
  • @ToniMichelCaubet check in logs that you have following logs: `"Building Google options"`, `"Building GoogleApiClient"`, `"GoogleApiClient built"`. Also reinstall up to start from beginning. Post also logs you see on Android related to google plus – Maxim Shoustin Sep 18 '17 at 11:20
  • @ToniMichelCaubet added EDIT 3, see error description – Maxim Shoustin Sep 18 '17 at 11:27
  • In the `cordoba build android` log from the terminal you mean? if so, no, there isn't any of this 3 logs ( even removing and installing the plugin).. ( thank for letting me know the description of the error.. turns out I'm the error :P ) – Toni Michel Caubet Sep 18 '17 at 11:44
  • Well, I don't see the logs. But finally it's working in Android and IOS (seems like reinstalling with the google.json it was enoguh). Thank you SO MUCH for your help! – Toni Michel Caubet Sep 18 '17 at 11:56