So I have a project with multiple libraries attached as submodules - this means I can't commit to them.
Each of the libraries already includes an android support library, which obviously leads to an error
Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define...
while trying to build apk.
Of course I can remove duplicate support libraries from library projects, but I won't be able to commit this changes, and as result use my repo with Jenkins, etc.
For now I see only one choice - fork libraries, remove conflicting jar from them, and use forked versions as submodules. But to be honest, I would like to avoid it.
So, is there any way to build apk with multiple support libraries, or exclude those libraries from git submodules while cloning them?
If you can automate (in a script) the remove of those duplicate libraries references, then you could register to those submodule repos a smudge
script that would, on checkout, remove those duplicate.
(from Scott Schacon's Pro Git book page on Git Attributes: section "Keyword Expansion")
Each time you update those submodule SHA1, that smudge script would automatically clean up that repo.
I do that on a submodule by copying the filter I want directly in parentRepo/.git/module/asubmodule/info/attribute
.
See this script for instance:
githubdir="${H}/.git/modules/gitlab"
if [[ ! -e "${githubdir}/info/attributes" ]]; then
cp "${gtl}/config.gitlab" "${githubdir}/config"
cp "${gtl}/attributes.gitlab" "${githubdir}/info/attributes"
xxgit=1 git --work-tree="${github}" --git-dir="${githubdir}" checkout HEAD -- "${github}"
With attributes.gitlab
being:
*.rb filter=fileExpandPath
*.rake filter=fileExpandPath
That would call:
fileExpandPath_replace
(which I trigger with the line above "git checkout HEAD -- /path/to/submodule
")fileExpandPath_restore
(which you might not need since you won't be doing any commit in the submodules)