Accessing git submodule in Android Studio
Solution 1
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.
Solution 2
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.
Solution 3
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.
Comments
-
bwoogie almost 2 years
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 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?
-
ivan.sim about 9 yearsGood job. I think now I understand your original question. Don't forget to accept your own answer :-)
-
vilpe89 about 4 yearsI think your problem was that you did not set the module as a dependency in your gradle-file. "It added itself to my project" well yeah, because you added it as a dependency now ->
dependencies { implementation 'net.danlew:android.joda:2.10.3'}
.