Jake warton
Jake warton

Reputation: 2203

How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio

I have one project on Gitlab and I worked with it for the last few days!

Now i want pull project on my home PC but show me below error :

Invocation failed Unexpected Response from Server:  Unauthorized
        java.lang.RuntimeException: Invocation failed Unexpected Response from Server:  Unauthorized
        at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassXmlRpcClient.handleInput(GitNativeSshAskPassXmlRpcClient.java:34)
        at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassApp.main(GitNativeSshAskPassApp.java:30)
        Caused by: java.io.IOException: Unexpected Response from Server:  Unauthorized
        at org.apache.xmlrpc.LiteXmlRpcTransport.sendRequest(LiteXmlRpcTransport.java:231)
        at org.apache.xmlrpc.LiteXmlRpcTransport.sendXmlRpc(LiteXmlRpcTransport.java:90)
        at org.apache.xmlrpc.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:72)
        at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:194)
        at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:185)
        at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:178)

My android studio version is 3.4 !

Upvotes: 132

Views: 78324

Answers (21)

Rishita Joshi
Rishita Joshi

Reputation: 425

To solve this problem you have to remove GitHub credentials from the window credentials. then your right GitHub username and password. you can find the window credentials in the control penal. this issue occurs when the GitHub username or password is wrong mentioned in window credentials.

Upvotes: 0

For me, I just closed Andriod Studio and re-opened and that's it the problem is fixed.

Upvotes: 1

Swaminath Bera
Swaminath Bera

Reputation: 49

The error comes because android studio cannot read credentials due to some problem or your github token credentials has expired

This answer works, but this approach also helps if you're already using GitHub token based authentication :

  1. Go to in AndroidStudio -> File -> Settings -> GitHub -> Remove the account
  2. Generate a new github token or update the existing one
  3. Add account again in AndroidStudio -> File -> Settings -> GitHub, Apply and Save
  4. Invalidate caches and Restart Android Studio

Upvotes: 0

Faisal Shehada
Faisal Shehada

Reputation: 1

For Android Chipmunk:

  1. File
  2. Invalidate Caches
  3. Invalidate and restart

This worked for me.

Upvotes: 0

Sheychan
Sheychan

Reputation: 2436

File -> Invalidate Cache And Restart worked in my case

Upvotes: 11

Alexandre Cavalcante
Alexandre Cavalcante

Reputation: 325

In my case, my token has expired... I didn't notice that the expiration was set for 7 days

Upvotes: 0

WhoisAbel
WhoisAbel

Reputation: 1679

I had the same issue,clone my project from gitlab and save credential.helper with command in terminal:

   git config credential.helper store

and

 git fetch

enter image description here

Upvotes: 29

Alireza Nazari
Alireza Nazari

Reputation: 141

try this: git config --global --unset http.proxy

Upvotes: 0

DEV PLANET
DEV PLANET

Reputation: 71

I faced the similar. Here are the steps that resolve my problem.

  1. Go To https://bitbucket.org/account/settings/app-passwords/
  2. Create a app password
  3. Then execute git config credential.helper store
  4. Run git fetch
  5. Then it will ask for password, enter the password that created from bitbucket console.

Then it work.

Upvotes: 7

slenderm4n
slenderm4n

Reputation: 302

I faced the same issue with Bitbucket and as they say Bitbucket Cloud recently stopped supporting account passwords for Git authentication. If you're using bitbucket here's what you need to do.

details : https://atlassian.community/t5/x/x/ba-p/1948231

  1. create an app password how to create app passwords

Allow the the appropriate permissions and create the password. once the password is generated you need to store it for later use somewhere else because you won't see it again.

  1. Goto AndroidStudio -> Preferences -> Git and tick the "Use credentials helper" and apply.

  2. run "git fetch" and the credentials helper will popup , and enter the saved app password and viola!

EDIT

followed following url:

how to use "git fetch" command

git fetch command

git remote add origin "git link"

it will ask the password

follow this link https://bitbucket.org/account/settings/app-passwords/

to create app password. and store it somewhere .It will require to place the password when asks.

git fetch
git pull origin master

that's all there you go.

Upvotes: 5

Ejaz Ahmad
Ejaz Ahmad

Reputation: 644

I faced this problem for my bitbucket account then I used terminal to get the exact error.

Below are my observations

1-git pull
fatal: Invalid credentials -- this was the error coming 
remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication.

After this I have to create app password from below link.

https://bitbucket.org/account/settings/app-passwords/

2-After setting all permissions it will create a password for you

3-Then use this password in credential manager or in terminal when it will task.

This is the latest issue I observed and solved hope it may help anyone.

Upvotes: 2

m3g4tr0n
m3g4tr0n

Reputation: 671

Here's what worked for me, I am running different ids on bitbucket and github

  1. Enabled Credentials Helper AndroidStudio -> File -> Settings -> Git -> Use credential helper
  2. Ran git config credential.helper store
  3. Ran git fetch through console once

Upvotes: 21

lucasddaniel
lucasddaniel

Reputation: 1789

Use these steps to git over HTTPS not SSH:

  1. git config credential.helper store
  2. You'll be requested the credentials username/token or pass.
  3. Check this in Preferences > GIT > Use Credential Helper The checkbox Use Credential Helper

Upvotes: 28

sifr_dot_in
sifr_dot_in

Reputation: 3603

i had logged to gitHub with access token
and it had expired.

so i fumbled here.

solution:

enter image description here

Upvotes: 1

mashhour darweish
mashhour darweish

Reputation: 41

In case you try to push from Android Studio 4 or above into Github and get this error message you have to re login into Github.

Android Studio -> Setting-> GitHub

if you can't login using username and password try to get a token from GitHub

https://github.com/settings/tokens

and then generate new token if you don't have one and login with Token just like the photo -

enter image description here

Upvotes: 4

Gpak
Gpak

Reputation: 3390

Enabling credentials helper worked for me, using Android Studio 3.6.2 on Windows 10

AndroidStudio -> File -> Settings -> Git -> Use credential helper

Upvotes: 207

Volodymyr
Volodymyr

Reputation: 6569

I had the same issue. Fixed it by adding SSH private key to the ssh-agent in the command line:

$ ssh-add -K ~/.ssh/id_rsa

Also, check if Git settings are set to Native

Settings --> Version Control --> Git in the SSH executable: dropdown, choose Native

EDIT It was fixed in the latest version 3.6.1 of Android Studio https://androidstudio.googleblog.com/2020/02/android-studio-361-available.html

Upvotes: 31

Adrian Coman
Adrian Coman

Reputation: 1536

Managed to fix it like this:

AndroidStudio -> Preferences -> Git -> SSH Executable and changed from Native to Built-in and it started working.

Edit: this is for Android Studio 3.4, for 3.6 Volodymyr has an answer below.

Upvotes: 66

Eltohamy Mohammed
Eltohamy Mohammed

Reputation: 71

file->setting->git-> SSH executable: dropdown, choose built in

Upvotes: 4

AllinProgram
AllinProgram

Reputation: 344

You can try this, don't use the shortcut([email protected]:/example/example.git) provided by logging in to git, submit directly using the full repo address(https://github.com/example/example.git).

Upvotes: 2

EypoRage
EypoRage

Reputation: 71

This Error seems to appear if your SSH Key Pair is secured with a password

The native SSH Executebale can not prompt you for your password in Android Studio afaik, so authentication will fail if the credentials are not provided otherwise.

Using the Built-in SSH Executable will let you enter your password via a prompt in Android studio.

The Answer provided by Adrian worked perfectly for me.

Upvotes: 7

Related Questions