LoginSignup

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

Android StudioからGithubにログイン不可、コマンドプロンプトからのpushが失敗

解決したいこと

Android Studioで作成したプロジェクトをGithubにpushすることができません。
その後コマンドプロンプトでも試してみましたが、やはりできませんでした。
特にエラーが出ているわけでもなく、push後にエラーが出ていないにも関わらずpushできていないという状況です。

解決方法を教えていただけると助かります。

発生している問題・エラー

エラーは特に発生していません。

自分で試したこと

gitコマンドをたたく手間を省きたいと、Android Studioとgitを連携しようと試みました。
やったことを1から順を追って書いていきます。
参考にしたサイトは以下です。
http://tech-fill.net/android-androidstudio-github/

1.gitのインストール確認

Microsoft Windows [Version 10.0.19042.985]
(c) Microsoft Corporation. All rights reserved.

C:\Users\tomoh>git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

---以下略---

⇒問題なし

2.githubユーザ登録
image.png

⇒済

3.Githubで開発者用トークンを発行
githubのSettings⇒Developper settingsから開発者用トークンを生成。
image.png

4.Android Studioからリポジトリ作成
image.png

⇒成功。
image.png

5.Githubにメールアドレス、ユーザ名登録

C:\Users\tomoh\AndroidStudioProjects\MyApplication2\.git>git config user.email
xxxxxxxxxx

C:\Users\tomoh\AndroidStudioProjects\MyApplication2\.git>git config user.name
xxxxxxxxxx

C:\Users\tomoh\AndroidStudioProjects\MyApplication2\.git>

これは以前設定していたので、git configで確認。問題なく表示されました。

6.Android Studioでプロジェクト作成
github連携だけを試したかったので、とりあえず空のアクティビティを作成しました。
image.png
HelloWorldと表示されるだけのものです。

7.Android StudioからGitHubへ接続
VCS ⇒ バージョン管理へインポート ⇒ Githubでプロジェクトを共用 
image.png

すると次の画面が表示されます。
image.png

ここで断念しました。。ユーザ名が間違っているのでしょうか。。
まだトークンを入れるところまでも行っていないのに何を使って認証しに行ったのかわかりませんでした。
参考にしたサイトでは、以下のようにLogin画面が出るということだったのですが・・・。
image.png

続いて、まじめにgitコマンドを打ってpushすることを試しました。

1.Githubで新規リポジトリを作成
image.png

HelloWorldという名前でリポジトリを作成しました。

2.init、add、commit

参考サイトの手順に従って、

git init
git add .
git commit -m "First commit"
を順に実行しました。
結果は以下の通り。

C:\Users\tomoh\AndroidStudioProjects\MyApplication2>
C:\Users\tomoh\AndroidStudioProjects\MyApplication2>git init
Reinitialized existing Git repository in C:/Users/tomoh/AndroidStudioProjects/MyApplication2/.git/

C:\Users\tomoh\AndroidStudioProjects\MyApplication2>
C:\Users\tomoh\AndroidStudioProjects\MyApplication2>git add .
warning: LF will be replaced by CRLF in .idea/encodings.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in gradlew.
The file will have its original line endings in your working directory.

C:\Users\tomoh\AndroidStudioProjects\MyApplication2>git commit -m "First commit"
[master (root-commit) a272c20] First commit
warning: LF will be replaced by CRLF in .idea/encodings.xml.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in gradlew.
The file will have its original line endings in your working directory.
 42 files changed, 817 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 .idea/.gitignore
 create mode 100644 .idea/.name
 create mode 100644 .idea/compiler.xml
 create mode 100644 .idea/encodings.xml
 create mode 100644 .idea/gradle.xml
 create mode 100644 .idea/jarRepositories.xml
 create mode 100644 .idea/misc.xml
 create mode 100644 .idea/vcs.xml
 create mode 100644 app/.gitignore
 create mode 100644 app/build.gradle
 create mode 100644 app/proguard-rules.pro
 create mode 100644 app/src/androidTest/java/com/websarva/wings/android/myapplication/ExampleInstrumentedTest.kt
 create mode 100644 app/src/main/AndroidManifest.xml
 create mode 100644 app/src/main/java/com/websarva/wings/android/myapplication/MainActivity.kt
 create mode 100644 app/src/main/res/drawable-v24/ic_launcher_foreground.xml
 create mode 100644 app/src/main/res/drawable/ic_launcher_background.xml
 create mode 100644 app/src/main/res/layout/activity_main.xml
 create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
 create mode 100644 app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
 create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png
 create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher_round.png
 create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png
 create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher_round.png
 create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png
 create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
 create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png
 create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
 create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
 create mode 100644 app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
 create mode 100644 app/src/main/res/values-night/themes.xml
 create mode 100644 app/src/main/res/values/colors.xml
 create mode 100644 app/src/main/res/values/strings.xml
 create mode 100644 app/src/main/res/values/themes.xml
 create mode 100644 app/src/test/java/com/websarva/wings/android/myapplication/ExampleUnitTest.kt
 create mode 100644 build.gradle
 create mode 100644 gradle.properties
 create mode 100644 gradle/wrapper/gradle-wrapper.jar
 create mode 100644 gradle/wrapper/gradle-wrapper.properties
 create mode 100644 gradlew
 create mode 100644 gradlew.bat
 create mode 100644 settings.gradle

Warningは出ていますが、問題ないように見えます。。

3.remote add origin

こちらも手順に従って、以下のコマンドを実施。
git remote add origin [手順1のQuick setupに記載されたURL]

C:\Users\tomoh\AndroidStudioProjects\MyApplication2>git remote add origin https://github.com/xxxxxxxxxxxxx/HelloWorld.git

C:\Users\tomoh\AndroidStudioProjects\MyApplication2>

特段エラーは出ず。

4.連携確認

git remote -v

C:\Users\tomoh\AndroidStudioProjects\MyApplication2>git remote -v
origin  https://github.com/xxxxxxxxx/HelloWorld.git (fetch)
origin  https://github.com/xxxxxxx/HelloWorld.git (push)

⇒問題なさそうに見えます。

5.push
いよいよpush

git push origin master

C:\Users\tomoh\AndroidStudioProjects\MyApplication2>git push origin master

C:\Users\tomoh\AndroidStudioProjects\MyApplication2>

エラーは特に出ません。

6.Githubで確認
image.png
何もpushされていない・・・。

原因思い当たる方いらっしゃいますでしょうか。
何か初歩的なことを見落としているのかもしれませんが、自分では調べられませんでした。

0

No Answers yet.

Your answer might help someone💌