Search code examples
google-drive-android-api

Android-quick start app with google drive is not working


I am trying to upload an image using quick start tutorial to google drive initially my app starts and asks to choose account but when I select an account it keeps asking again and again.


Solution

  • As shown in the code, no account name is passed. Try setting useDefaultAccount() method which will specify that the default account should be used when connecting to services. Otherwise, use clearDefaultAccountAndReconnect() method if you prefer setting up multiple accounts. This method will clear the account selected and will prompt the user to pick an account before reconnecting.

    See GoogleApiClient for more information regarding sign_in.

    In addition to that, see also installation and configuration of the Google Play services SDK regarding creation of credentials.

    If you haven't done so, check credentials created for your project. Here are the steps:

    1. Open the Credentials page in the API Console.
    2. Follow these steps if your application needs to submit authorized requests:

      a. Click Create credentials > OAuth client ID.

      b. Select Android.

      c. In the Package name field, enter your Android app's package name.

      d. Paste the SHA1 fingerprint into the form where requested.

      e. Click Create.

      Otherwise, follow the steps below, which are for applications that only need to make unauthorized API calls:

      a. Click Create credentials > API key.

      b. Select Android key.

      c. Paste the SHA1 fingerprint into the form where requested.

      d. Type your Android app's package name into the form where requested. e. Click Create.