简体   繁体   中英

Compiling an Android package from Google git repo

I am trying to get a specific package (Launcher2) from the google git repo and compile it. Planning on changing a few things and create a custom one. After installing git i used this to get the source from the tag of the 2.2 sdk:

git clone https://android.googlesource.com/platform/packages/apps/Launcher2 launcher2
git checkout android-sdk-2.2_r2

After all done and the files exist, I am creating a new android project in eclipse and choosing the 2.2 target framework and marking the "use existing source". The project is opening but with many compilation errors like invalid imports and unrecognized fields and so on ... It looks like the source I have does not match the framework. What am I missing?

Ahhh... But you do know if you have the entire repo and the device tree in place, that you can build just one package. Assume for a moment, that your environment is Linux based and that your device handset is a Samsung i9000 (Galaxy S), then in your source tree you would have device/samsung/galaxys , which contains proprietary libraries and extra code related only specifically to the hardware for the Samsung i9000.

Then its a matter of having to do this as a once-off operation -

. build/envsetup.sh

lunch

Pick Samsung Galaxy s from the lunch menu. This is the tricky bit in ensuring your device handset appears on the lunch menu!

make -jX 

(Replace X with the appropriate number of cores your processor has)

Your entire system.img/boot.img would be deposited in out/target/product/samsung/galaxys after a couple of hours depending on how fast your machine/environment is.

Now, to build one package you simply enter this:

make Launcher2

Now you will have a new android app called Launcher.apk that will be deposited in out/target/product/samsung/galaxys/system/app directory.

How?

Simple, when after doing a ' lunch ', and invoke this command

make modules > modules_list.txt

The resulting output will contain the names of modules in that file modules_list.txt , that can be built on the command line - modules in the context of the entire AOSP source tree, it can be a (static|shared) library, native executable or even Android Java app.

Now, do not bother cleaning out the entire out/ tree (even though that can swallow up a lot of space), leave that in there to speed up the build process of individual modules.

If you really really want to delete them, issue this:

make clean && make clobber

and the entire out/ directory is removed and gone for good.

if you want to compile in Eclipse, you will not be able. Because it uses internal classes (com.android.internal.*) and private APIs.

See Launcher 1 (until android 2.1) : http://code.google.com/p/android-launcher-for-sdk/

Otherwise, you can have a look on the source code of ADW Launcher 2 which is based on Launcher2. You will see the modification made to be compliant with the public APIs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM