I have downloaded Android source code but I don't find the "Kernel Directory" in the top level directory of the source code tree. Is it ok? Or is it missing?
/mydroid$ find . -name kernel
./bionic/libc/kernel
./vendor/htc/sapphire-open/kernel
./vendor/htc/dream-open/kernel
./dalvik/libcore/luni-kernel/src/test/java/tests/api/org/apache/harmony/kernel
./dalvik/libcore/luni-kernel/src/main/java/org/apache/harmony/kernel
./prebuilt/android-arm/kernel
./prebuilt/android-x86/kernel
./device/htc/passion/kernel
default.xml in https://android.googlesource.com/platform/manifest does not point to the kernel, so repo would not automatically download it. Most kernel trees are specific to machines anyway.
See http://elinux.org/Android_Kernel_Download for information on getting the right kernel.
git clone https://android.googlesource.com/kernel/common.git kernel
Related
Is there a way to build an Android system app from AOSP without having to clone the entire code tree and having to build the entire OS?
Just being able to build the unmodified app from a Linux shell is sufficient, with any toolchain that will do the job. Being able to make modifications in an IDE (Eclipse or Android Studio) is not a requirement (a text editor will do for making changes).
The app in question is CarrierConfig. Most of the app is just assets, the code consists of just one single Java class (~400 lines of code), but with four internal dependencies not exposed through the SDK API:
android.annotation.Nullable
android.os.PersistableBundle.restoreFromXml(XmlPullParser)
android.telephony.TelephonyManager.from(Context)
android.telephony.TelephonyManager#getCarrierIdFromMccMnc(String)
These are what prevents me from simple adding a generic build.gradle and running it through the gradle toolchain. The build artifact is a simple APK file, with which I would then patch the system image.
So how would I build this app without needing the entire AOSP source code (just the actual dependencies, and dependencies of dependencies etc.)?
Not a complete answer (yet), but some snippets I was able to find out so far:
Downloading just individual projects from the source tree
This is what I have been able to piece together from various instructions—untested so far:
mkdir <dir>
cd <dir>
repo init -u <url> -b <branch>
repo sync <project-list>
Where
<dir> is a dir on your system where you are going to keep the source
<url> is the URL for your build, e.g.:
AOSP: https://android.googlesource.com/platform/manifest
LineageOS: https://github.com/LineageOS/android.git
<branch> is the branch to check out (omit -b to check out the master branch)
AOSP branches are found at https://source.android.com/setup/start/build-numbers#source-code-tags-and-builds
LineageOS branches are found at https://github.com/LineageOS/android/branches
<project-list> is a list of projects to fetch (if omitted, repo sync will fetch the entire source tree). Projects can be indicated either by their name or by their path within the source tree, separated with spaces.
(source 1, source 2, source 3, source 4)
Figuring out which repos you need can get tricky, and if your dependencies have further dependencies, this can become a time-comsuming process.
Also I haven’t figured out if the next step actually works with a source tree stripped down in this manner.
Building individual projects
If you just need to build a single project, you can use mmm for that:
. build/envsetup.sh
lunch
mmm path/to/the/project/
(source)
I have used this command to archive a git source code:
git archive --format=tgz -o ~/myproj-20180402.tgz --prefix=myproj/ master
Are there same/similar way to archive a AOSP repo branch or tag. How to do ? Any help would be greatly appreciated.
AOSP code is not a single git project, it's actually many more (hundreds). So there is not a git command per-se.
What you could do is use repo this way:
repo forall -j16 "<your-git-command-1; your-git-command-2>"
So for the exact git command you proposed it would be:
repo forall -j16 "git archive --format=tgz -o ~/myproj-20180402.tgz --prefix=myproj/ master"
But keep in mind there is not a single git project, so you will end up with hundreds of archives, each inside it's root dir. Check the manifest you sync for a full list of projects and it's location locally.
Currently I'm using the the AOSP ROM Builder image on Amazon AWS to build Android.
The point is, I'm only interested in the external tool grxmlcompile that is built for the host (linux) in the path: aosp/out/host/linux-x86/bin
where the source is at aosp/external/srec/tools/grxmlcompile
I'm not very familiar with Linux and make files, hence my difficulty to get this going.
I would like to copy the source (if needed the whole tree) and build just this tool on another linux machine.
I can't find the make file I need to run to build just this part.
UPDATE:
Looks like make out/host/linux-x86/bin/grxmlcompile would do the job. I would still like to be able to port only the needed parts of the source tree to the build machine
cd to the top of your Android build source.
source build/envsetup.sh
cd external/srec/tools/grxmlcompile
mma
...or any directory, or sub-directory a makefile. From AOSP build/envsetup.sh
m: Makes from the top of the tree.
mm: Builds all of the modules in the current directory, but not their dependencies.
mmm: Builds all of the modules in the supplied directories, but not their dependencies.
To limit the modules being built use the syntax: mmm dir/:target1,target2.
mma: Builds all of the modules in the current directory, and their dependencies.
mmma: Builds all of the modules in the supplied directories, and their dependencies.
external/srec was removed from the platform/manifest after android-5.1.1_r4 tag. So later, if you are using a manifest such as revision 5, 6 or later, you may need to do git clone https://android.googlesource/platform/external/srec external/srec to include that directory.
I've just cloned the Android kernel (via git clone) repository but for some reason, none of the source files are there. Instead there is just a massive .git folder, which I think has the kernel source code in it. How do I 'unpack' that git repository so I can get a workable source tree?
The exact command I've used was git clone git://android.git.kernel.org/kernel/common.git android-kernel.
git config core.bare returns false
git branch returns * master
git checkout master returns Already on 'master
The files seem to be there but they are packed. I really don't care about preserving integrity of the repository, I just want the source tree, without any of that stupid git crap.
In android they use their own tooling which uses git under the hood:
I am not sure how to get a kernel built working if you directly clone git repo, for their own tooling here are the docs:
http://source.android.com/source/downloading.html
Old question, but - The answer above is, indeed, incorrect. You have to cd to the directory you've cloned, then run git branch -a, and checkout the relevant one:
bash-3.2# git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/android-2.6.39
remotes/origin/android-3.0
remotes/origin/android-3.3
remotes/origin/android-3.4
remotes/origin/android-3.4-compat
remotes/origin/coupled-cpuidle
remotes/origin/experimental/android-3.8
remotes/origin/experimental/android-3.9-rc2
remotes/origin/linux-bcm43xx-2.6.39
remotes/origin/master
Then:
bash-3.2# git checkout android-3.4
Checking out files: 100% (38819/38819), done.
Branch android-3.4 set up to track remote branch android-3.4 from origin.
Switched to a new branch 'android-3.4'
Then, at last:
bash-3.2# ls
.git Documentation README drivers ipc samples usr
.gitignore Kbuild REPORTING-BUGS firmware kernel scripts virt
.mailmap Kconfig arch fs lib security
COPYING MAINTAINERS block include mm sound
CREDITS Makefile crypto init net tools
I followed the directions on http://source.android.com/source/downloading.html to get the Android source code. Now I have downloaded 2 GB of stuff, most of the space is taken by .pack files. Now how do I access the code?
I tried
git unpack-objects < pack-78609e1ab8b627ff3b749e8d4c78e86e096de3d8.pack
the output is:
Unpacking objects: 100% (14014/14014), done.
Is this the correct way to access the source code and where does it unpack to? Where's the output dir?
Git internally uses objects that are explained here http://book.git-scm.com/1_the_git_object_model.html. These objects may be compressed together in a pack. Anyhow, I do not expect you have anything to do with objects and/or packs. So, could you give a bit more detail on the steps you did and the files you ended up with? (Note: I'm not familiar with the Android repo-tool, but I am with git)
the unpacked files are put in the local .git directory. Use:
git checkout master
to put them in the local directory.