Accessing git submodule in Android Studio

I’m just starting out using source control for my own project, and now I want to add Joda-Time. I want to add it as a submodule so I went into the terminal and executed:

git submodule add https://github.com/JodaOrg/joda-time.git

and it downloaded all the files successfully. Then I ran:

  • git pre-commit hook format code - Intellij/Android Studio
  • app-release-unsigned.apk is not signed
  • Git case-sensitivity error — renaming and committing from Android Studio
  • Android studio 1.4 and VCS (git) can not commit code
  • Remove old and add new git in android studio
  • Android Studio: SDK location changes for same project using Mac (OSX) and Windows
  • git submodule init
    

    And got nothing back.

    git submodule status
    

    returns

    b9fe534c7f5876eced6494a6d6c1deaf2528a579 joda-time (v2.7-17-gb9fe534)
    

    I checked my projects root directory and I see the new joda-time directory and it’s source. But now how do I access the library in my project? Did I miss a step?

  • Reduce size of git repository on Bitbucket
  • How can I change the default comments in the git commit message?
  • How to release automatically your artifact to GitHub
  • Git push: username, password, how to avoid?
  • How to interactively (visually) resolve conflicts in SourceTree / git
  • version control: how to control css and js compressed/minified versions between environments
  • 3 Solutions collect form web for “Accessing git submodule in Android Studio”

    Try with git submodule update --init. This will allow you to do git submodule init and git submodule update in one step. Note that you only need to add the --init option once.

    Quoting from the doc:

    update

    Update the registered submodules to match what the superproject
    expects by cloning missing submodules and updating the working
    tree of the submodules.

    On the other hand, git init by itself simply

    copying submodule names and urls from [your] .gitmodules [file] to [your local] .git/config [folder].

    Once you did this, you will notice that your submodule is in a DETACHED state. You can simply checkout any existing branch from there, say, git checkout master to checkout upstream master branch.

    You missed git submodule update. From the docs:

    Update the registered submodules to match what the superproject
    expects by cloning missing submodules and updating the working tree of
    the submodules.

    You can also do it with the --init option, which will do the git submodule init for you.

    I wasn’t able to have any luck with the answers provided. As I kept searching the internet for a hint of help I stumbled across Joda-Time-Android so I removed the original Joda-Time submodule and tried again with the new. It works! It added itself to my project and it’s ready to rock!

    During the time I was still troubleshooting the original issue Joda-Time doesn’t include a build.gradle file but Joda-Time-Android does – I think that was the problem.

    Git Baby is a git and github fan, let's start git clone.