Push Android Library to Github [duplicate] - android

This question already has answers here:
Detach (move) subdirectory into separate Git repository
(26 answers)
Closed 5 years ago.
I've made a 2-module project where one module is completely denoted to a library that I've made and I'm accessing that library from the other module(which contains the MainActivity.java) of the project. Now I want to push only my library to the GitHub so that anyone can use it for their need. I know how to push the entire project to GitHub but How can I extract the library ( module ) from the project and push only that. Thanks in Advance!

Based on my understanding, your root project is already versioned under git. If so then to version your library module as a separate git repo and also use it within other git repo projects, then you need to use git-submodule. The module will be pushed as a separate Android Project. Once that is done, you'll add the library to your app project by using git-submodule and configuring the settings.gradle to include the library module for compiling. And finally, add a dependency in your app build.gradle file to include the library in the app compilation.

This is so simple, maybe I misunderstand your need
git add <modulename.extension>
git commit -m "added single module"
git push origin master

Related

Multiple repositories for modules in android studio

I am trying to convert my existing application into a number of modules.
Is it possible for me to have each module pointing to a git repository so I can grant access to people accordingly?
So my structure is like this
APP --> Git 1
Module 1 --> Git 2
Module 2 --> Git 3
...
Is this possible for me to do with an android studio project?
The idea is for me to be able to give different developers different modules and not let them access other modules. I have never used git this extensively so dont really know how this works
Please help
Nikhil
Yes, Android studio supports multiple git repos.
you will have something like:
Repositories:
Repo 1 -> master
Repo 2 -> feature/branch-name
in AS Select VCS, VCS popup and import or check out repo. Or you can create new repo in your folder and and independently in subfolders.

Remove module as library from git using android studio

I was using a project as module dependency in Android Studio. I no longer now need it. So I removed the dependency from build.gradle file and then committed and pushed it. When i take a fresh check out using git in Android Studio, i am able to see that module, even though that is not being used by my project. If i check on the git site, the folder is still there. I think i need to delete it from the cache of the git which maintain the history of this. But I do not know the commands to run in the Android studio terminal to completely remove it from git respository.
Project Structure
Project
|
-app
-build.gradle(removed dependency of module 1)
-Module1
-Module2
-module3
-settings.gradle(removed module1)
Want to remove module1 from the git. Please let me know the commands.

Creating standalone android library project using Android Studio (0.8.14)

I see there is option to create module/ android library project with in a project, but don't see any way to create a standalone library project/module that could be shared across different projects. It used to be very simple in Eclipse. When I try re-using an existing module within a different project, AndroidStudio simply creates a copy of that module in new project. Thats what I don't want, I want to re-use my existing code. This link seems to have answer I'm looking for, but not working for latest build for Android Studio.
There are a couple of ways I've tried doing this, a quick and easy way to do this is to symlink your library module directory to a directory in your project and add it to your settings.gradle. A better way to do it is to import the library module as a VCS project (local git works fine) It will still clone the library module into each project but changes made to the library will be consistent across all of the projects using it.

Adding Google Cloud Messaging to existing Android project

The android docs recommend you add the gcm library project located at $ANROID_HOME/extras/google/google_play_services/libproject/google-play-services_lib/, however I don't want to clutter my eclipse workspace with a useless project.
After checking the contents of the project I noticed that there is no real code, only a jar (google-play-services.jar) and a bunch of resource files.
My question is: If I'm only going to use GCM, is it possible to just put that jar in my maven repo as opposed to importing the Android library project?
I'm not sure if I get your question. To be able to use GCM, you just need to Add google-play-services.jar in your project path.
I successfully added the library by Project>Properties>Java Build Path > Libraries (tab) > Add External Jars and selected the library from C:\Program Files\Android\android-studio\sdk\extras\google\google_play_services\libproject\google-play-services_lib\libs
Hope this helps/

Developing a Git library project that's also a submodule of another project

I have an Android application under development which makes use of a separate library project of my own. These two projects are stored in separate Git repositories. The application project references the library project by means of the .gitmodules file.
I'm now trying to work on both of these projects together (the application and the library) on a new machine. I cloned the application project, which resulted also in the library project being automatically cloned into my ~/git/ directory as well. So far so good.
I notice also that in Eclipse Package Explorer, the library project root has a commit hash within brackets (e.g. [MyLibraryName 0123ABC]). This presumably means that the library clone is from a certain commit point, and I understand that I could update this (i.e pull in the latest commits for this library) using git submodule foreach git pull.
Question is, what is the best way for me to continue separately developing the library project now? I tried to modify a file and stage it, but when using Team->commit, the dialogue didn't list the modified file. I assume this might be something to do with it being a submodule, pointing at a particular commit.
Should I clone my library project again, completely separately into a different subdirectory, and import as a separate project into Eclipse in order for me to do work on that library?
Having read various other SO questions, it seems apparent that there's no elegant solution for this. The steps I eventually took to solve this are:
Assuming not done so already, clone the application repository that makes use of submodules. Import all projects into Eclipse workspace, including the submodule repository (or repositories). Note that the submodule repository is a repository within the main application repository, and it's not on a particular branch; it's a reference to a particular commit (detached head).
In the Package Explorer, rename the submodule project that was imported. I gave it a name that relates to the application repo it's inside of. For instance, for an application project called ABCD, rename it from SomeLibrary to SomeLibrary_ABCD.
Next, clone the library separately from its own Git repository. Now, the point of renaming the submodule project is that it's now possible to import the Eclipse project from the standalone clone of the library repository, without Eclipse giving the "Some or all projects can not be imported because they already exist in the workspace" error.
Having done this, we have SomeLibrary_ABCD project which is not on a branch but points to a particular commit, and is a submodule of project ABCD. That submodule is updated using git submodule foreach git pull. Then, we have project SomeLibrary, which is on a branch (e.g. master).
My planned workflow is to locally switch the application project to point at my 'standalone' project of the library instead of the submodule version when I want to do development on the library. I then commit changes to SomeLibrary.
Any better suggestions than this (or corrections to anything I've stated) would be appreciated - but for now this is my own answer to the problem.

Categories

Resources