How to build android AOSP to a specific target product - android

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

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 for Qualcom Snapdragon 800 msm8974 chip on Samsung Note 3

Hi I have been working on compiling an android image for my Samsung Note 3. Basically I downloaded the source from Samsung, which directed me to download a version of Android Open Source Project code. I then followed the procedures in the readme files provided. But there are some discrepancies between the procedures and tools to be used from Samsung vs. Qualcomm's documents. My question is about finding the right procedure, and get a working image. I have followed the Samsung's procedures, and they have not resulted in a working image as of now. I tried to flash the boot.img file I created, and collected the recovery logs which are posted here I could be doing something wrong though; I am not saying the procedures are wrong. So here are the issues I am struggling with:
1- Samsung's readme file says to download arm-eabi-4.7, while Qualcomm says to used 4.8 with their compiler add on llvm. As of now, I plan to try llvm with 4.7 and 4.8 and see what happens. I have already tried 4.7 w/o llvm and it has not helped.
2 Samsung procedures state to update the CROSS_COMPILE statement with the path to above arm-eaby-4.7 executable, export ARCH=arm, then create a config file with the following statement:
make VARIANT_DEFCONFIG=msm8974_sec_hlte_spr_defconfig msm8974_sec_defconfig SELINUX_DEFCONFIG=selinux_
defconfig
and then run make. While Qualcomm's llvm readme file states to issue the following command:
ndk-build NDK_TOOLCHAIN_VERSION=snapdragonclang3.6 APP_ABI="armeabi-v7a"
-C <some_project>
I know I have to have a path to ndk-build script and I know where it is. What I do not know is
1- If Samsung's procedures run ndk-build also. I looked through the Makefile in the project's root directory and do not see any reference to it. Would the arm-eabi-4.7 run ndk-build perhaps?
2- What is the best way to get to a working image for me? I do not see the NDK_TOOLCHAIN_VERSION and APP_ABI variables in the Samsung's .config file. Can I set these as environment variables?
3- Samsung's procedures state to set an environment variable of ARCH=arm, while Qualcomm's configuration passed to the ndk-build is armeabi-v7a
4- Qualcomm's procedure calls for a project name. Is this something generic or would I find it somewhere in Samsung's files? I did a search in the .config and Makefile and did not see any reference to it.
5- Are there any tags I should add to this post to get the attention of right folks who know and deal with questions like mine stated above?
#jww - Thanks. I'll try the procedure, and I am going through the material you shared. I hope I can have my other questions above addressed also.
Update - Hey I noticed I did not get any reply about actual issue. Another question I wanted to ask is if it helps to build an image, which provides more information about what is wrong with my image? Do I do that via the config command?

Is there a nice guide to making android apps by hand with just a text editor (e.g. no eclipse ide)?

I want to create apps manually. Using eclipse is the easy way. Using just a text editor is the hard way, but ensure I will know exactly what I'm doing, which is how I like to work.
Are there any good tutorials out there?
EDIT 3:31pm 10/17/2011: I realized what my question should have really been after googling around: Are there any good resources that describe the directory contents of an Android project in detail? The idea here is to be able to create them manually.
Google tells you all about how to manage things from the command line here. Pretty straight forward.
That said, I think I'd have to recommend against going low level here. I used emacs and ant for several months while learning/tinkering with android programming, but it wasn't really that helpful. The whole android system seems designed for use in an IDE: use of XML for layout, automatically generated values in R.java, a big API with many similar sounding names (layouts vs views, OnTouchListener vs OnClickListener), etc. I can't say I really started to get the big picture of the system until I could see it all organized for me. I'm still on the command line for a lot of C/C++, and even some Java stuff too, but all it did for android was cause frustration.
EDIT
Just saw your edit for the directory structure. Check here.
If you must...
First install ant, then assuming sdk/tools is in your $PATH:
android create-project -n projectname -t android-13 -k here.namespace.your -a MyActivity -p projectname
Where android-13 is an installed platform, run android list targets to see which platforms you have. Then run ant release or ant debug to build, or just ant to get a list of possible targets. When you're ready to test, run ant install to install it onto a running emulator or attached device.
See Tools in the dev guide.
Intel xdk. Do the whole app in html, css, php, and javascript. Inel xdk can build it in different platforms.(android, iphone, and windows.)
Yes, there is a way.
See this link:-
http://animeshrivastava.blogspot.in/2017/07/generate-android-app-apk-on-shell-or.html
I am attaching the relevant parts :-
Generation of Android app at command prompt of Windows will be as follows:
Install Java .Only install version 6 standard edition as it is small size compatible with Android.
Next install Android in folder.
Run Android package manager and put Android API level 23 platform tools for version 6 of Android lollipop in directory
.This will have a file Android.jar containing all class files as a library jar for making a DALVIK-EXECUTABLE file run and execute as app on Android lollipop mobile.
Set path environment variable in advance system settings of Windows. Include java-installation in path variable.
Lets use shortcut mypro for my project. Mypkg means my package. Make directory folder
Note that com.pkg is a package where dot or period separates com and pkg sub directories.
In case your package doesn't have this dot or period, then during compilation no error but when you install in mobile, it will say invalid
Now we generate R class for res directory.
enter code hereaapt p -S res -J ./com/pkg -I android.jar

Project from https://android.googlesource.com

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

How can I compile Dalvik to run it locally on Linux?

What are the minimal steps necessary (including retrieving the source code) to compile and run just the Dalvik virtual machine on Linux?
Actually , I got Dalvik working on my elementary OS installation.
First download the Android AOSP source tree using https://source.android.com/source/downloading.html. Wait for it to download (2 hours for me cloning only the current commits and Marshmallow branch)
After running build/envsetup.sh while in the source tree run lunch full_x86-eng. Then type make -jN (replace N with number of cores).
WAIT. This took me about 1 hour on an AMD-4500M laptop. Newer ccomputers may be as low as half and hour and older ones might take half a day.
Change directory to !!AOSP-PATH!!/out/host/linux-x86/bin/ and run export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:!!AOSP-PATH!!/out/host/linux-x86/obj/lib/ or
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:!!AOSP-PATH!!/out/host/linux-x86/lib
or export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:!!AOSP-PATH!!/out/host/linux-x86/lib64
TRY ALL OF THESE
and then
./dalvikvm --32. If you try to run without the --32 option it will crash (don't know why)
Working Marshmallow Dalvik. To get the GUI apps working you will need to do some more porting and coding which is another project which I am working on.
Took me half a day to figure this out.
References
http://milk.com/kodebase/dalvik-docs-mirror/docs/hello-world.html
Use sabayon Linux. This is a distro that can natively run Android programs and all Linux ones too.
Actually, that's rather android running on Dalvik and the underlying system is already linux.
I guess running a bare Dalvik VM on a desktop linux box is just a matter of getting the sources and compile it.
The GUI stuff is something else.
You are not the only one with this idea, and that is great in internet society terms.
This is probably what you are looking for: http://www.android-x86.org/.
Those guys ported android over to x86.
It still works as an OS, so I'm not sure if you can run Linux and Android(Linux) together without using VirtualBox.
Dalvik runs on Android. The authors of Dalvik are only worrying about it running on Android, as far as we are aware.
Various groups have indicated they are working on getting Dalvik outside of Android. You are probably best off finding and talking to them.
In other words, there are no official instructions of the type you seek.
Sorry!
Getting apps designed for Android to run on Linux is going to be tricky. However, it is possible to run a Dalvik VM on Linux. In fact, this GitHub project has a pre-compiled binary of Dalvik VM for Linux, ready to use! Check the associated blog post for information about how the binary was compiled and how to use it.
Learn to program Java \ C \ C++ and other frameworks
Modify the Android source (I think app_process or something) so it shows a windows on the Linux desktop (learn X11 / Wayland APIs)
Below is a simpile base for you to start with
www.android-x86.org/getsourcecode
Getting Android-x86 source code
First, follow this page to configure your build environment. Then
mkdir android-x86
cd android-x86
repo init -u git.android-x86.org/manifest -b $branch
repo sync
Where $branch is any branch name described in the previous section. This will point the projects created or modified by android-x86 to our git server. All the other projects still point to AOSP.
We also have a git mirror server on SourceForge.net. To use it, you only need to change the repo init command to
repo init -u git.code.sf.net/p/android-x86/manifest -b $branch

Categories

Resources