Objective:Because of the work required, often to compile the dynamic library under the Android, the company has already set up the environment of the server, but the first oneself want to build a understanding of the whole process, in addition, the company's servers are often problems, resulting in compilation can not, so I want to build the environment. Started with the company's own computer installed a unbuntu virtual machine, and then found on the Internet a strategy to start building the environment. But always stuck in the source download that piece, every source code download error, as described in the following question 1. Intermittent, are working outside the spare time to get a get, but always download unsuccessful, I thought is the company network problems, network instability, so download old failure. Would like to try a few more times, think that there will always be a download success, but one weeks past, has not been successful, and later impatient, on the shelve no tube.After one weeks, a colleague applied for a desktop to start the installation of Ubuntu, I suddenly whim, I want to put a unbuntu in my home computer to play, and then go home and start to install a dual system. Here, I'm going to throw up a groove. A vicious Microsoft, my machine originally installed is Win7, when pretending to think that later installed two systems late in the installation of Linux, so reserved for 80G of space. But when I was pretending to be unbuntu, I found that it could only detect I have two disks, a C drive and a D drive. I do not understand, I clearly have c,d,e,f four disk, now I remove the F-disk, it should also have three disk and 80G of the remaining space ah. Finally found that is the basic partition and dynamic partition problem, if the Win7 when it automatically gave me a dynamic partition (so-called dynamic partition is the capacity of the disk can be dynamically modified without formatting, when the fashion system does not understand, also did not notice the problem), dynamic zoning is not suitable for dual system, What you see is four disks, actually only two disks. In the online search a lot of information, want to do not damage the existing data in the case of the dynamic partition into a static partition, many people on the web said can not turn, but still do not forget, finally found a can not lossless transform dynamic partition into static partition software, excited to download down, conversion. Restart the computer, the tragedy occurred, unable to find the boot file, the system can not start. No way, can only re-install Win7, good re-install Win7 later found a few other disk things are still, and indeed become static partition (I think it should be my operation has a problem, this software is very powerful). Install Ubuntu, do not know what to do, think of the Android build environment to build up. Too much nonsense, look at the following compilation process and the problems encountered it. Source code download and compilation: in http://source.android.com/source/ Initializing.html website, there are detailed steps, my system is ubuntu12.04, so the compilation given below is for the system, if your system is not the same, please refer to the site for other systems on the environment to build methods. 1. Tool installation $ sudo apt-get install Git-core GnuPG Flex Bison gperf build-essential \Zip curl Libc6-dev libncurses5-dev:i386 x11proto-core-dev \libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \Libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \Python-markdown libxml2-utils xsltproc zlib1g-dev:i386 $ sudo ln-s/usr/lib/i386-linux-gnu/mesa/libgl.so.1/usr/lib/ I386-linux-gnu/libgl.so This step basically did not encounter problems, very smooth. 2. Source code Download $ mkdir ~/bin $ path=~/bin: $PATH $ curl Https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo $ chmod a+x ~/bin/repo $ mkdir androidsource $ cd Androidsource if you want to download the current latest version, then: $ repo init-u HTTPS://ANDROID.GOOGLESOURC E.com/platform/manifest if you want to download a specific version, then: (I downloaded the 4.0) $ repo init-u https://android.googlesource.com/platform/ Manifest-b ANDROID-4.0.1_R1 This step will require you to enter a user name and a mailbox, input on the line, I feel this mailbox does not seem to use. $ repo Sync This step will take a long time, please ensure that your network has been active, in addition I encountered the following problem 1, you can first look to avoid this problem. 3. Compile $ source build/envsetup.sh $ lunch Full-eng $ make-j4 This step encounters problems 2 and 3. How long is this step specific? I'm not sure, I made it up before I went to bed at night, the next morning the compilation is complete, the last big information is as follows: Note: To learn more, please use-xlint:deprecation to recompile. Target Java:ctsaccountmanagertestcasES (Out/target/common/obj/apps/ctsaccountmanagertestcases_intermediates/classes) Note: Some input files use or overwrite outdated APIs. Make: * * * [out/target/common/obj/apps/android.core.tests.libcore.package.com.no-core-tests-res_intermediates/ Noproguard.classes-with-local.dex] has killed make: * * * waiting for unfinished tasks .... Not sure if there was an error, but I found that it didn't affect me to compile the dynamic library, so I didn't control it. 4. Compile the dynamic library or the static library into the directory: >> CD ~/androidsource/out/target/product/generic Create a new folder in this directory, such as driver, then you can build your C program in this directory, Compile the dynamic library. Here I give a very simple example, create a new C file, implement the Add (int a,int b) function. (1). c file as follows: #include int add (int a,int b) {return (A+B);} (2) Create a new android.mk file, note that the file name cannot be changed as follows: Local_path: = $ (Call My-dir ) include $ (clear_vars) local_module:= HelloWorld local_src_files: = hello.c local_module_tags: = optional local_module_p ATH = $ (Local_path) include $ (build_shared_library) (3) Configure environment back to source directory: >> cd ~/androidsource >> source Build/envs etup.sh >> Lunch Full-eng back to the Dynamic Library directory: >> ~/androidsource/out/target/product/generic/driver compile: >> mmAfter compiling, the HELLOWORD.C will be generated in the current directory and you will be able to invoke the library elsewhere on Android. Of course, if you want to call the library in Android app, then the name of the excuse function must be modified, this is another problem, here is not detailed. Error encountered and workaround: 1. Error: Fatal:http request failedThis problem also bothered me for a long time, started because the Google website is not stable, so often connection failure, online has a lot of people suggest with thunder download. Finally in the online someone gave a solution, in/etc/hosts add the following code: (The role of the file is to provide IP and domain name correspondence between the DNS server is to provide this role, it should appear to be a problem with the DNS server, resulting in source code download failure) 74.125.31.82 www.googlesource.com 74.125.31.82 android.googlesource.com 74.125.128.93 dl.google.com 74.125.128.136 dl.google.com 2. Error: "Your version is:1.7.0, the correct version Is:java SE 1.6." Analysis: The main reason for this error is that the version of the JDK on this machine is too high, and the JDK version required for Android compilation is 1.6. because it Built the Android app development environment, also need the JDK, so at that time on the official website to find a new version 1.7, so there will be an error. Workaround: The workaround is simple to say, uninstall the jdk1.7, reinstall 1.6 on the line. But the actual operation took me a long time because of the jdk1.6 installation problem. First of all, when the installation of jdk1.7 when the tar.gz format of the file, download it directly extracted in the corresponding directory, and then add the path. But the official website about the 1.6 version only. bin format files, downloaded down when installed, appears "rpm:rpm should not being used directly install RPM packages, use Alien instead! Rpm:however Assuming you know is doing ... error: Dependency detection failed:/bin/basename was jdk-2000:1.6.0_38-fcs.i586 required "This error The reason for this is that RPM is the package manager of the Redhat system, Ubuntu is the Debian department, and the Debian Package Manager is dpkg, which needs to be installed with the Deb package instead of the RPM package. The workaround is: >>sudo alien-k jdk-6u38-linux-i586.rpm Note that this RPM file is generated by the. bin file that you just ran, and then generates a. deb package >>sudo dpkg-i jdk_1.6.038-1_i386.deb I encountered a hint error at this step, I forgot what was wrong, and then I always reinstall, or prompt error, I changed the other 1.6 version, still hint wrong, finally on the Internet, a person said, do not bother about this error, In fact, the installation has been successful, I just modified the environment variables, generally under the/usr/java/jdk1.6.0, and then recompile, sure enough, tossing and dying. 3. Question: External/yaffs2/yaffs2/yaffs_tagsvalidity.h:23:6: warning:redundant redeclaration of ' yaffs_InitialiseTags ' [- WREDUNDANT-DECLS] External/yaffs2/yaffs2/yaffs_guts.h:888:6: note:previous declaration of ' Yaffs_initialisetags ' was Here host C:mkyaffs2image <= EXTERNAL/YAFFS2/YAFFS2/YAFFS_TAGSVALIDITY.C host C + +: Obbtool <= frameworks/base/ Tools/obbtool/main.cpp:0:0:warning: "_fortify_source" redefined [enabled by default] reason: gcc and g++ compiler version too high WORKAROUND: Replace the lower version of the GCC and g++ compilers to view the compiler version: >>ls-l gcc* lrwxrwxrwx 1 root root7 19:26 gcc-gcc-4.6-rwxr-xr-x 1 root root 353216 Apr 07:37 gcc-4.6>>ls-l g++* lrwxrwxrwx 1 root root7 Mar 04:05 g++-g++-4.6-rwxr-xr-x 1 root root 357312 Apr 07:36 g++-4.6 install gcc and g++4.4 versions: sudo apt-get install gcc-4.4 g++-4.4 g++-4.4-multilib Modified link: >>sudo mv gcc gcc.bak >>sudo ln-s gcc-4.4 gcc >>sudo mv g++ g++. Bak >>sudo ln-s g++-4.4 g++ View current gcc and g++ versions: >>gcc-v >>g++-V
4. Questions
/home/user/bin/repo:line 1:syntax error near unexpected token ' newline '
/home/user/bin/repo:line 1: ' <! DOCTYPE html> '
Solution:change a repo
Curl"Http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" >~/bin/repo
5. Problem
fatal: ‘../platform/abi/cpp.git‘ does not appear to be a git repository
fatal: The remote end hung up unexpectedly
error: Cannot fetch platform/abi/cpp
在.repo目录下的manifest.xml里找到fetch属性 改成 fetch= "git://Android.git.linaro.org/ "
6. problem
Host staticlib: libglcommon (out/host/linux-x86/obj/static_ Libraries/libglcommon
_INTERMEDIATES/LIBGLCOMMON.A)
Host sharedlib: libgles_cm_translator (out/host/ Linux-x86/obj/lib/libgles_cm_tra
nslator.so)
/USR/BIN/LD: cannot find -LGL
Collect2: ld returned 1 Exit Status
Make: * * * [out/host/linux-x86/obj/lib/libgles_cm_translator.so] Error 1
Workaround:
sudo apt-get install Libglu1-mesa-dev
sudo ln - s /usr/lib/i386-linux-gnu/mesa/ libgl.so.1.2 /usr/lib/libgl.so
7./usr/bin/ld:skipping incompatible/usr/lib/gcc/x86_64-linux-gnu/4.4.5/appears at compile time. /.. /.. /libz.so When searching For-lz error
Host Executable:aapt (OUT/HOST/LINUX-X86/OBJ/EXECUTABLES/AAPT_INTERMEDIATES/AAPT)
/usr/bin/ld:skipping incompatible/usr/lib/gcc/x86_64-linux-gnu/4.4.5/. /.. /.. /libz.so when searching For-lz
/usr/bin/ld:skipping incompatible/usr/lib/gcc/x86_64-linux-gnu/4.4.5/. /.. /.. /LIBZ.A when searching For-lz
/usr/bin/ld:skipping incompatible//usr/lib/libz.so when searching For-lz
/usr/bin/ld:skipping incompatible//USR/LIB/LIBZ.A when searching For-lz
/usr/bin/ld:cannot Find-lz
Collect2:ld returned 1 exit status
Make: * * * [OUT/HOST/LINUX-X86/OBJ/EXECUTABLES/AAPT_INTERMEDIATES/AAPT] Error 1
missing Lib32z1-dev, installation: Apt-get install Lib32z1-dev
8. Target R.java/manifest.java:ctsverifier (Out/target/common/obj/apps/ctsverifier_intermediates/src/r.stamp)
Warning:AndroidManifest.xml already defines Versioncode (in http://schemas.android.com/apk/res/android); Using existing value in manifest.
Warning:AndroidManifest.xml already defines versionname (in http://schemas.android.com/apk/res/android); Using existing value in manifest.
Warning:AndroidManifest.xml already defines minsdkversion (in http://schemas.android.com/apk/res/android); Using existing value in manifest.
Target Java:ctsverifier (out/target/common/obj/apps/ctsverifier_intermediates/classes)
Cts/apps/ctsverifier/src/com/android/cts/verifier/passfailbuttons.java:191:oncreatedialog (int, Android.os.Bundle) in android.app.Activity cannot implement Oncreatedialog (Int,android.os.bundle) in com.android.cts.verifier.PassFailButtons.PassFailActivity; Attempting to assign weaker access privileges; was public
private static <t extends Android.app.Activity & passfailactivity>
^
1 Error
Make: * * * [Out/target/common/obj/apps/ctsverifier_intermediates/classes-full-debug.jar] Error 41
Solution:comment the statement of Cts/android.mk, and then all the files in CTS would not be compiled.
CTS means "Compatibility Test Suite", when we finished the development of Android, we must pass the CTS, and make sure tha T all the application can run normally in this platform, then hand over this test report to Google and get the Authenticat Ion of Android Market.
ubuntu12.04 build a summary of the Android build environment