1

I've just upgraded my Android Studio to 2.1.1 last night. Before upgrading I shared one of my android studio project to gihub successfully with my previous version of android studio. Today when I'm trying to share another project into github, it is showing the following error message:

enter image description here

I followed some answers given here in stackoverflow Android Studio - Push failed: fatal: Could not read from remote repository but nothing worked for me.

Here are some screenshots of VCS setting. enter image description here

enter image description here

enter image description here

Here are some error messages:

17:26:42.195: cd /home/imran/AndroidProjects/Implicit_Intent
17:26:42.195: git -c core.quotepath=false push --progress --porcelain origin refs/heads/master:master --set-upstream
java.io.IOException: Authentication failed: 
    at org.jetbrains.git4idea.ssh.SSHMain.authenticate(SSHMain.java:299)
    at org.jetbrains.git4idea.ssh.SSHMain.start(SSHMain.java:173)
    at org.jetbrains.git4idea.ssh.SSHMain.main(SSHMain.java:138)
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

I've tried by changing the SSH Executable from Built-in to Native, but got the same error.

I am using Ubuntu 14.04. How to resolve this problem?

Community
  • 1
  • 1
Abdullah Al Imran
  • 1,166
  • 2
  • 17
  • 30

2 Answers2

0

Make sure you are connecting with the right public key. The error looks like your public key is not added to the account you want to use for pushing. If you expect your username and password to be used instead, you have used the wrong URLs. The SSH URLs git@github.com:... are not using username / password for authentication (username is git, hence the git@) but you are identified by the public key you use for authentication which has to be added to your GitHub account. To use username / password authentication you have to use HTTPS URLs like https://github.com/abdalimran/Implicit_Intent.git instead.

Vampire
  • 35,631
  • 4
  • 76
  • 102
0

As you know, GitHub is a web-app above git repositories. So there are technically 2 independent parts - GitHub web interface with API, and actual GIt repositories. And Android studio interacts with these parts in different ways.

The account/password (or token) you specify in Settings - Version control - GitHub allows access to the web-part. It is used to get the list of the repositories available for the account, create new repositories, pull requests and other operations of the web-part. That is why the repository for your new project was created but was empty.

To work with repositories (commit, push, pull, etc) IDE uses stand-alone command-line git client. After the repository is created, IDE passes the gut push command to the client. If the git client prompts for credentials, IDE shows you a prompt or passes the cached/configured credentials. GitHub, however, does not support login/password access for SSH connections.

To access GitHub repositories through SSH you need to add your public key to your account and use it to authenticate.

More details here: https://help.github.com/articles/connecting-to-github-with-ssh/

As an alternative, use HTTPS URL

Dmitrii Smirnov
  • 7,073
  • 1
  • 19
  • 29
  • Is it a private key or a public key? And what to do after adding key to github account? How to use Https connect? – Shubham Agarwal Bhewanewala Sep 05 '17 at 03:27
  • Of course, it is the public key, id_rsa.pub by default, that you add to the account settings. Updated the post. After you add the key, you can use SSH to connect to projects. It is not related in HTTP connection in any way, so you could continue using HTTP – Dmitrii Smirnov Sep 05 '17 at 07:48