Project from https://android.googlesource.com - android

If I download a project from https://android.googlesource.com to what Android API version will it be compatable ?
I have cloned a project.
Then created a project in Eclipse in that name with its res, src and manifest.xml, but still its shows error with some variables declaration missing , some functions arguments changed/not correct etc.
Any idea?
I'm using sdk_r08, and android 2.3 project working well.
Does the project from https://android.googlesource.com need any dependent files? If so what do I need to get those files?
Is there any extra arguments that I can set in git clone to get the project in a specific version?

You need to use the repo tool , then you can use the -b parameter to checkout a specific branch, see repo documentation for examples.

Actually you cannot load only a single project into eclipse since the whole OS tree is mutually dependent,
you have to checkout the whole source code, make a compile and then copy the .classpath in the root folder of the build and create a java project using this classpath. and ONLY then will you be able to load a project.
however note that the AOSP compiles only on 64bit Ubuntu 10.04 (version and distro is mostly because of library versions and dependencies, I've seen people do it on fedora and suse)
the compile is horrific however you ARE compiling an OS from scratch so ...
it takes about 5 hours on a dualcore pentium u 3gigs of ram..
and about 20 mins on i7 with running
make -j16
after importing everything in eclipse you can work with individual applications like, Launcher, Contacts, Calendar, Phone.. etc..
however to actually install anything on a real device (without flashing the whole rom) you have to refactor/rename the project package declaration since most of them are com.android.* which means the device will not override the default app installed
in short, after setting up the workstation:
(don use -b gingerbread since it is the bleeding edge branch, numbered versions are production branches so bugs are minimal)
repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.4_r1
repo sync
. build/envsetup.sh
lunch 1
make -j8
most of the flags I am using are explained in the tutors below...
More info on the subject:
Workstation setup : http://source.android.com/source/initializing.html
Downloading source ; http://source.android.com/source/downloading.html
Building : http://source.android.com/source/building.html
and most important.. howtos...
http://www.youtube.com/watch?v=1_H4AlQaNa0
http://www.youtube.com/watch?v=rFqELLB1Kk8

Related

How to build a portion of Android source in Android Studio without cloning entire android library?

I am trying to better understand a portion of the Android source code.
But instead of just reading it, I'd like to have it in Android Studio and be able to modify it and re-build, run it, etc.
In the past I have done this by simply copying the Java file/s in question from the source code into Android Studio one-by-one, renaming them and changing their package name to my own... and fixing any broken dependencies.
This way of doing things has worked for simple classes such as RadioButton.java, but the "portion"/module I'm trying to "import" now is all the files in the tts package.
So, I found TextToSpeech.java online, copied and pasted it into Android Studio, renamed it MyTTS.java and changed the package name to mine... and started going through the "unresolved symbols" and repeating the process as necessary...
But, since this tts package is much "deeper" in the Android code tree, I've run into several obstacles with resolving the broken dependencies (non-public components, aidl files, annotations, and more!) which I could just ask individual questions for, but before I try that, I was wondering if there is already some established way to do this that doesn't involve importing the entire Android library into Android Studio).
Probably your best bet is to clone the Android Source code repository, limiting what you download and then using the idegen.sh command to generate an Android Studio project which will give you full access to the source from within Android Studio.
To clone the minimum amount of Android Source, make sure you specify a specific branch to the repo command, limit the git depth to 1 and specify a git partial clone. These will speed up your clone, but it still will take some time.
E.g.
$ repo init --depth=1 -u https://android.googlesource.com/platform/manifest -b android-9.0.0_r46 --partial-clone
...
$ repo sync -j 4
...
Once that's downloaded, you can run the idegen.sh command to generate your Android Studio project file:
$ source build/envsetup.sh
...
$ lunch aosp_x86-eng
...
$ mmm development/tools/idegen/
...
$ development/tools/idegen/idegen.sh
...
You'll then find the Android Studio project files at the top of the AOSP tree. Note that indexing will take a long time to complete each time you open the project.

How to build android AOSP to a specific target product

I am trying to generate a rom to install in my phone which is a Motorola 1Gen Codename Falcon. I have followed both instructions from the official tutorial on source.android.com and also this tutorial.
Summing up what I did:
set up the build environment
Get the AOSP source:
repo init -u https://android.googlesource.com/platform/manifest
repo sync
Get the device tree and kernel for Falcon:
git clone github.com/CyanogenMod/android_device_motorola_falcon -b cm-14.1 device/motorola/falcon
git clone github.com/CyanogenMod/android_kernel_motorola_msm8226 -b cm-14.1 kernel/motorola/msm8226
(I removed the https:// because my account can only post two links)
Defined the target architecture:
. build/envsetup.sh
lunch aosp_arm-eng
and finally build it:
make -j8
Accordin to this tutorial from xda-developers I posted, after the successful build, it was going to create a .zip file to be flashed at out/target/product/*CODENAME*. But it created only a out/target/product/generic with a system.img file and not a out/target/product/falcon as I expected (was my expectation right?).
So anyway, did I miss something important in the process of making it? How to correctly make for my target? Thanks in advance.
Cyanogenmod is no longer actively developed or supported. It has become LineageOS, so your best bet is to look there. Building Cyanogenmod (or LineageOS) is slightly different than what is described on AOSP. Look here for specific instructions for the Moto G: https://wiki.lineageos.org/devices/falcon/build
You're intentionally building for generic, though you're not aware of. lunch aosp_arm-eng sets the target. aosp_arm-eng is not the falcon you want to build for, it's the very generic.
To build for falcon, pick the correct item from lunch menu.
If the Target Platform suffix is what you are looking for, then there are two solutions:
Using a separate output directory:
$> export OUT_DIR=out_armv7
This will override the default out/ directory for your target binary.
Searching in the out/snoog/ directory (Android > 7.0) and find Target Platform specific .mk file, e.g. Android-asop_arm.mk

AOSP: How to build /platform/frameworks/base or /platform/frameworks/support separately in Android Studio

Is there a way to build AOSP's /platform/frameworks/base package source or support library source separately in Android Studio.
I wanted to read the framework (base and support) code in Android Studio and since I didn't want to be bothered about the rest of the packages in AOSP, I only imported the mirrored repo of these two packages as two separate projects in Android Studio. I want to browse through the code by using "jump to source" shortcut (cmd/ctrl+click) of the IDE. But this handy feature won't simply work properly in Android Studio. When I try to jump to the method definition which belongs to a different java source file (It says - "Cannot find declaration to go to"). This limitation of source editor is due to gradle build failure. The project just won't build and throws the following error.
Error:You need a symlink in prebuilts/sdk/99 that points to
prebuilts/sdk/current.Without it, studio cannot understand current
SDK. ln -s ../../prebuilts/sdk/current ../../prebuilts/sdk/99
Is there a way to fix this. I know I can simply browse the source code on http://androidxref.com/ too, but it's not as convenient and powerful as your IDE.
This is possible (having Android Studio be able to show you the framework code and let you use the usual IDE tools), though compiling won't work.
But the detail in your question seems to indicate you don't actually care about compiling, just about viewing/editing.
The first steps listed here:
http://ronubo.blogspot.com/2016/01/debugging-aosp-platform-code-with.html
might work for you. Basically:
Build your AOSP platform
( . build/envsetup.sh && lunch - && make ...)
Create the Android Studio project for importing to
( mmm development/tools/idegen && development/tools/idegen/idegen.sh )
Import the project
( open android.ipr from Android Studio)
Not without a huge effort.
For very many reasons.Ex:
1.the framework depends on different HALs and libraries from system/bionic/external
2.Compiling the framework uses specific tools from linux(flex,bison,libgl etc..)
3.Framework is built using the Android.mk system and needs a lot of flags and compilation macros from build/
I also can't imagine a motivation to do what you are trying to do. If it's going to run on any device, bare in mind device manufacturers modify the framework heavily, even the small ones. Actually the chipset manufacturers modify it and give it to manufacturers that modify it even more.
Error:You need a symlink in prebuilts/sdk/99 that points to prebuilts/sdk/current.Without it, studio cannot understand current SDK. ln -s ../../prebuilts/sdk/current ../../prebuilts/sdk/99
This notice already tell you should run the command:
ln -s ../../prebuilts/sdk/current ../../prebuilts/sdk/99
To tell build system use 'current version sdk' in prebuilts/sdk/current directory replace the temp sdk version 99.
could you try it?

android source code building

I have already the complete source code of android 4.0. How can I bring it to git so that I can compile and build it through ubuntu 14.04 LTS? Actually I want to build custom ROM.
Is there any other way of compiling and building it?
You do not need to put android source code to git, in order to build it. AOSP is a set of projects (hundreds) which already are in their own repos, at github or other hosts.
You should follow build instructions for your AOSP ROM. For example here it is for CyanogenMod built for Samsung Galaxy S4 mini LTE (serranoltexx)
https://wiki.cyanogenmod.org/w/Build_for_serranoltexx
If you'll be customizing a ROM and you want to put your changes to git, I think it would be right to fork changed repos and modify your repo manifest to use the forked repos.

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?
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
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.

Categories

Resources