Configure Android Studio with Bitbucket team repo

2020-05-14 15:42发布

问题:

I am trying to configure Android Studio to work with my team repo on Bitbucket. What I would like to do in the first place is to push my local project onto my team's repo.

I have already installed the Bitbucket plugin but don't really know where to go from here. When I try to commit the changes, all I get is "No changes detected".

回答1:

Without Using Any Plug-in


  1. First from VCS menu of android studio select Enable Version Control Integration, it will ask you for selecting versioning tool, select git from the drop down.
  2. Create new repository in the BitBucket account for the project, selecting git as the repository type.
  3. Now from the terminal window at the bottom of android studio, type: git add -A This will add the files to git for committing.
  4. To commit with a message type git commit -m "First Commit" in the terminal. Here, First Commit is just a message i used for demonstration.
  5. From Bitbucket, in the newly created repo, select I have an Existing Project from below. It will give you two command line commands. Use Them consecutively. These will add the local repo to the bitbucket. First one: git remote add origin https://example@bitbucket.org/example/test.git Second one: git push -u origin master
  6. Add again git add -A
  7. Then Commit git commit -m "Second Commit"
  8. Push for the last time git push origin master

  9. You can check that the branch is up-to-date by writting git status

    On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working tree clean

  10. Done . My Android Studio version was 2.3.3 & git version 2.13.0.windows.1


回答2:

So I am assuming you have a local project and you need to import it into your Repository in BitBucket. Since you already have the BitBucket plugin installed, follow the below steps:

  1. Goto VCS Menu > Import into version control > Share Project
  2. You will have to give your credentials when prompted.
  3. On the next dialogue, give a name and a description to your project and then click OK

Now you have got your project imported to BitBucket. Now to checkout a project from BitBucket:

  1. VCS > Checkout from version control > BitBucket
  2. Select the project you want to checkout

After you have added the project to BitBucket, you will see a menu called Git in you VCS menu, which has all the options of Git.

Now depending on the version of android studio and the BitBucket plugin you are using, you are likely to get some errors while doing these. I did these using Android Studio 0.8.2 and Bitbucket plugin version 1.2.2.

Also make sure in the Android Studio Preferences > Version control, the directory is set to <Project> and the VCS to Git. Unless you are using Mercurial or anything it is advisable to remove any VCS other than Git from there. If all these are right everything should be working well.



回答3:

There is a bug in the third-party Bitbucket plug-in which is preventing it from working, although you can still configure Android Studio to work with Version Control.

  1. Create a repository on Bitbucket.
  2. Clone it via VCS > Checkout from Version Control > Mercurial or Version Control > Git.
  3. Use the HTTPS or SSH URL shown in the "Clone" tab for the repository on Bitbucket as the Repository URL.
  4. Copy and paste your local project into your cloned repository.
  5. You may now use Android Studio to work the repository.


回答4:

1)Android Studio -> VCS -> Enable version control

2)Right click on your root directory ->select git ->Add 3)Then click on ctrl+K 4)Write your commit msg 5)Click on Define Remote 6)Paste your git repository url . 7)and final step is PUSH



回答5:

//Easy tutorial on android studio with bitbucket (linux)

  1. create bitbucket repository "testp"
  2. create a folder "gtest" on your local machine
  3. go to this local folder("gtest") with cd command
  4. now clone git repository "tesp" with clone command
  5. this repo "testp" folder must come inside that "gtest" folder now
  6. open android studio and create a project "MyApplication" by selecting the project location folder "testp"
  7. now open terminal and go to path with cd command upto that tesp folder (you can use terminal inside android studio)
  8. now hit ls command and it should show your project dir "MyApplication"
  9. on your terminal type command "git add MyApplication/". 10.now enable vcs by clicking menu on vcs and enable vcs ...
  10. once the vcs is set or enable then select your appliation "MyApplication" project >> right click >> git >> commit directory >> may write comment "initial commit" and hit "push and commit" button.
  11. see event log for more detail
  12. check out the repo it should be there.
  13. if you have to pull this project only then goto "MyApplication" project >> right click >> git>> repository>> pull

Note: here "testp" , "gtest" and "MyApplication" are only example

If you have already android project then

  1. select menu(vcs) check out from version control
  2. click clone and copy repository from bitbucket and paste it on dialog given by selecting menu1
  3. On the second menu provide specific location where you want to clone
  4. After clone is success it will ask something like create project, anyways click yes.
  5. Now project is created 6.right click on the project and clik new> add module > import project(this is where you import the already existed android project) 7.After every thing is done, build.gradle may have build problem ,if occur paste following code :

    buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' } }

    allprojects { repositories { jcenter() } }

  6. now cd up to your bitbucket clone folder using android terminal

  7. now add everything inside this folder using git command "git add file1 file2 file3"
  8. And lastly right click on your project and goto git>commit directory> commit and push and its done 11.You have your code push and commit on bitbucket : check it out
  9. done

// clone on other computer

clone the bitbucket project using vcs option and load project(not import) after it get clone

if this not work:

vcs clone to desired directory((click no ,if it ask something like yo have check out an android studio project..Would you like to open it)) and import the project using exact same location of clone directory(use gradle wrapper if asked : it may download so wait) and lastly enable vcs for push and commit.



回答6:

Here is what you can try.

  1. Android Studio -> VCS -> Enable version control
  2. Android Studio -> Changes Review all files and commit. At this stage you might have to add your files to VCS manually.
  3. Now you can share it on Bitbucket by VCS-> Share it on Bitbucket

Note:- For bitbucket you will have to install "following Bitbucket plugin" for Android Studio. http://plugins.jetbrains.com/plugin/6207?pr=androidstudio



回答7:

You need to add the files to your local repository first. Go to menu VCS -> Show Changes View. Add all the files. Then got to menu VCS -> Import into Version Control -> Share project.

You will be ask to enter the bitbucket origin URL. And that's it.