How to backup an AOSP project on GitHub - android

I have an Android project composed of AOSP, and other code in an Ubuntu environment. As you know, I used git and its associated tool repo to download AOSP according to the procedures on android source site. Now I want to have a way of controlling the changes I make to the environment. I have read about Git, but perhaps not enough to know what is the best way to do this. Maybe I already have this capability just by using Git locally? So my question is: What is the best way to save state in my build environment please, and how do I save this on Github as a remote backup repository? I believe I need to have a .gitignor file to exclude object files? Basically I have a WORKING_DIRECTORY with all of my code in there. That directory has a .repo and .git directory in it.

You will find that most or all of your changes will be under certain branches. For me, I develop roms for the Nexus 9 so a lot of my changes are under device/htc/flounder. The common branch is frameworks/base/ where I also make a lot of changes.
To this end I have two separate git repos that store these:
https://github.com/seanashmore/frameworks_base
https://github.com/seanashmore/device_htc_flounder
To create these, I created a github account. Then went to each of he top level folders i.e. frameworks/base and device/htc/flounder and ran the command 'git init'. This initializes those directories as git repositories. You also need to create the repos on your github account, this will give you url's for you to 'push' your code to.
The initial push of frameworks/base will take some time as it is quite large, but once you have done that first push its very handy to keep track of your code changes and all the other benefits that git brings.
A very handy git guide can be found here: http://rogerdudler.github.io/git-guide/
If you need any more information or help just ask.

Related

Upload all projects to one github repository

I have several projects on my laptop. I would like to upload all of them to GitHub and in one repository called Android-projects. After searching the web and being bombarded by different material I got confused. How can I do that? I didn't quite understand the answers found on this website. All my attempts failed.
I have GitHub Desktop and Git Shell installed on my laptop, but don't know how to use them.
Nothing much to do there:
Create an empty directory and add it to git or create a project on github and clone it to get the empty directory
Add your projects one by one to that directory and checkin
NOTE: Tracking changes will become a bit tedious with this appropriate. You will need to be careful if you are working on multiple projects at the same time.
In the main project folder where all your android projects are present, initialize a git repository there. git init
now create a repository on github.
Finally, add (push) your code to github.

Backup of Project in Android Studio

We all know that How much the Backup of the project is vital in the programming, when specially you are making a major changes in your code to experiment something new. But eventually you came across to fact that last changes that you have made earlier were correct. Or sometimes you just messed up your whole project. So there must be Backup of project for that.
So Do you know a way to take a local backup into other location of your machine as we know mySql , Visual studio do. I know only a single way and that is to just copy the project from project explorer and and past it some where else.
Do you know any other way of taking such type of back up. (I do not want to take back up over the internet. Thanks)
Android studio is powered by Intellij and it has inbuilt support for Local History.
Local History, which is your personal real-time version control
system. Local History is independent of external version control
systems and works with the directories of your project even when they
are not under any VCS control.
Local history is cleared when you install a new version of IntelliJ
IDEA or when you invalidate caches. Therefore, check in the changes to
your version control system before performing these operations.
Source - official IntlliJ documentation
Detailed description of Local Hostory feature here
Local History is independent of external version control systems and
works with the directories of your project even when they are not
under any VCS control. It applies to any structural artifacts: a
project, a directory or package, a file, a class, class members, tags,
or selected fragment of text.
Unlike usual version control systems, Local History is intended for
your personal use, it does not support shared access.
With Local History, IntelliJ IDEA automatically tracks changes you
make to the source code, results of refactoring, and state of the
source code based on a set of predefined events (testing, deployment,
commit or update).
Local History revisions are marked with labels, which are similar to
versions in traditional version control systems. Labels based on
predefined events are added to the local revisions automatically;
besides that, you can put your own labels to the project artifacts to
mark your changes. Reverting or viewing differences are performed
against these labels.
As showed in the comments, you can use git local. Once started git in your repository you can make all the changes and commits, create branches, tags and everything useful to control the versions of your application.
More info see: Git Basics - Getting a Git Repository
One way how you can take backup of all the code is using GIT as mentioned above,
in one more answer, I found these steps very useful -
it will generate a zip file of the project resources -
git init # on the root of the project folder
git add . # note: android studio already created .gitignore
git commit -m 'ready to zip sources'
git archive HEAD --format=zip > d:/archive.zip
Note: If you intend to send this by email, you have to remove gradlew.bat from zip file.
Reference answer
From experience, GitHub has been the best option. But remember, saving code only is not the safest way. Never forget your Keystore!!! Without it, you can never update a package on the store, you will lose all billing licenses and Firebase tools...the list is endless.
In short, GitHub your code, and manually back up that keystore file.

how do you create a patch across multiple AOSP projects?

The process documented here is for making a change to a single project (aka git repo).
But the change I have (implement a single new piece of functionality) spans multiple projects, is it possible to create a single patch to do this or does this need to be broken up into seperate interdependant patches?
I think you should divide your patch into patches for each project. Here is the logic why I think this. Each Android project has it's own .git directory, i.e. these projects are in separate git repositories. Repo tool is just an addition over git commands, i.e. it does not provide you with new functionality. Thus, you cannot create a patch that will span across the projects (because they are not connected). Therefore, you need to divide your patch into separate patches for each AOSP project that is affected by your new functionality.
To create a project wide diff, use this command:
repo diff > /path/to/store/patch/all-changes.diff
Next, one can also use repo forall -p -c git status to check the status of each project.
repo forall -p -c git diff will show diff for each project.
Even I am trying to figure out how to generate patches for individual projects. However, if you understand the AOSP source, all the projects are coming from aosp_root/.repo/manifests/default.xml
If you try something like repo forall -p -c git diff > /path/to/patch/change.diff, this file will contain all the patches. I still haven't figured out how to extract the -p part, which prints the project name (Usually is a relative path inside the aosp_root), and convert it into a patch name.
However, these things are really not hard to in a bash environment with some scripting. Heck, I think repo is also open source, meaning you could even modify it youself!
If you take a look at this manifest, you should notice that the projects are interpreted same way as git repo projects which are easy to clone and reproduce the patches for. Though very similar to git, AOSP folder structure varies from device to device, SOM to SOM. It makes it a little harder to actually create individual projects due to path and other dissimilarities.
One thing that I am familiar with is using a tool like splitpatch on linux machines to split out the patches. However, this tool like others, will find splitting AOSP patches since many files have the same name, for example, if you change Android.mk across multiple projects, the patch splitter finds it hard to understand this structure, so it thinks that the same file was modified over and over.
If you refer the AOSP documentation, for anything, you'll find a good amount of information. Now you will need to use non-traditional search techniques to actually find most of them. The AOSP Documentation that Google provides on the web is not sufficient to understand everything. It's just a starting point.
The actual documentation is found inside the specific project. If you look at the Readme files under that project, or the docs/ folder, then you might find something more relevant.
It's easy to say that it's not well documented, but actually the problem is in exposure and organization. Documentation is available abundantly, finding it often is the problem.

Do I need SVN to download this project?

Android newbie here and would like to create a basic app using the AndriodPlot library.
The instructions to download are:
svn checkout https://androidplot.jira.com/svn/ANDROIDPLOT/
trunk/Examples/Quickstart Quickstart
Is there a way to download without SVN so I can get started?
If not, what SVN and how do I use it?
I assume it is some sort of version vcontrol but after Google-ing SVN, I am getting a lot of different answers and it is not clear what I am suppose to do...
Any point in the right direction to download this is greatly appreciated.
Yes, you need SVN to download this project.
What is ment by SVN is Subversion.
Depending on the platform you are using, you have to install a Subversion client. Under linux distributions, just search for the subversion in repository.
Under Windows and Mac OS X you'll find a graphical client, that will suit your needs.
You could download all the files manually or work on individual files e.g. https://androidplot.jira.com/svn/ANDROIDPLOT/trunk/Examples/Quickstart/src/com/example/MainActivity.java
but it's gonna be easier to just install svn and then checkout the repository and get a copy of the files on your machine.
Red bean did a good intro and guide when I was learning it http://svnbook.red-bean.com/en/1.1/ch01.html
And PS. learn GIT (better and now widely used)

What is Repo and Why does Google use it?

When I wanted to get Android source code, I knew that I have to use "repo". So what is repo? Why do they use repo and not just use GIT?, and is there a GUI for repo that enables me to pause/resume syncing, because every time I get disconnected occasionally it seems that repo starts syncing from the beginning!
As is mentioned in the android webpage, repo does not replace git. It is just a tool over git and helps you to manage multiple git repositories.
For example, suppose I have a big project which has a lot of features and I have several teams working on each feature and I created one repository for each feature. For example suppose my repositories are wifi, telephony, power management, etc. This action has sense when your features have different life cycles. For example if I won't touch the wifi feature in my next release and but I will modify all the rest. So under this scenario, my project or product is distributed in several different git repositories.
So, to get a centralized photo of my project (one specific moment of my project, for example a milestone), I need to get the revision (git hash or tag) of each repository. Remember that we have one repository for each feature. Manually I could do it but could be very painful. So, with repo you can have one MANIFEST which links to all the revisions of each git repo (one for each feature) and have an specific picture of my whole project.
Simply, I could say that is a way to manage centralized multiple git repositories which are decentralized.
With repo you have more features, not only to checkout at a specific point. For more info go to http://source.android.com/source/using-repo.html.
Repo and git - what they are, what they are for - is explained on source.android.com
To work with the Android code, you
will need to use both Git and Repo.
Git is an open-source version-control system designed to
handle very large projects that are
distributed over multiple
repositories. In the context of
Android, we use Git for local
operations such as local branching,
commits, diffs, and edits.
Repo is a tool that we built on top of Git. Repo helps us manage the
many Git repositories, does the
uploads to our revision control
system, and automates parts of the
Android development workflow. Repo is
not meant to replace Git, only to make
it easier to work with Git in the
context of Android. The repo command
is an executable Python script that
you can put anywhere in your path.
There's no GUI for Repo, as far as I can tell, but there's quite a bit of guidance on the site above for controlling what Repo is doing from the command line.
Concerning the pause and restart point, whilst in a terminal window doing a repo sync you can hit, "ctrl + z" to pause the repo sync. To restart simply type "fg" into the same window.
Go to:
http://source.android.com/source/git-repo.html
and you can download the repo script. It is a Python script that uses the git command to do distributed source code revision.
After you have executed repo sync, do a ps -auwf to see the processes:
For mine I saw:
\_ python -E /sde3/root/download/android/android/.repo/repo/main.py --rep
\_ git fetch korg
\_ git fetch korg
\_ git index-pack --stdin -v --fix-thin --keep=fetch-pack 5227 on
Yes, repo sync breaks often. But it is robust, just restart the command and it will resuming syncing again - those that have been updated will not be re-applied, so it will skip over them and continue with the rest.
repo sync has various useful options:
-f recovers from disconnects
-c just uploads the branch you asked for
-j <#CPUS> speeds up the sync by increasing the number of cpus used by the command

Categories

Resources