Friday, June 29, 2012

[Solved]emulator: ERROR: You did not specify a virtual device name, and the system directory could not be found.

Problem: After building AOSP and trying to lunch the emulator, coming up with this error:
               emulator: ERROR: You did not specify a virtual device name, and the system directory could not be                            found. 

               If you are an Android SDK user, please use '@<name>' or '-avd <name>' 
               to start a given virtual device (see -help-avd for details). 

               Otherwise, follow the instructions in -help-disk-images to start the 
               emulator 

Solution: type ./emulator -help-disk-images, then you would know how to fix it.

[Copied] Altering system.img, userdata.img, persist.img

If you have started building the Android source tree yourself, you have undoubtedly wondered how to modify the image files.  In this post, we'll look specifically at system.img.  This is based on the work found here.

Let's pretend our directories are:
~/work/android: directory where you did your git, envbuild, lunch/choosecombo from.
~/work/tmp: empty directory for us to play in
~/bin: directory on your path

If you have already done a build, you will find out/target/product/generic/system.img.  This is a YAFFS2 file.

Preparation

In my case, I did not have a way to mount yaffs2 filesystems.  I am sure I could have done some insmods and such; but instead, I chose to just compile this unyaffs.

~/work/tmp$ wget http://unyaffs.googlecode.com/files/unyaffs.c
~/work/tmp$ wget http://unyaffs.googlecode.com/files/unyaffs.h
~/work/tmp$ gcc -o unyaffs unyaffs.c
~/work/tmp$ cp unyaffs ~/bin
~/work/tmp$ rm *




Extracting system.img

~/work/tmp$ cp ~/work/android/out/target/product/generic/system.img .
~/work/tmp$ mkdir tmp2
~/work/tmp$ cd tmp2
~/work/tmp/tmp2$ unyaffs ../system.img

((modify files... for example, etc/init.goldfish.sh))


Rebuilding system.img

~/work/tmp$ rm system.img
~/work/tmp$ ~/work/android/out/host/linux-x86/bin/mkyaffs2image tmp2 system.img

Now you should be able to use the new system.img with your emulator =)


userdata.img and persist.img

These are handled in exactly the same way, just change the filenames.


Source Link: http://malsandroid.blogspot.com/2011/07/altering-systemimg-userdataimg-and.html



[copied] Modify Emulator's system.img


As a followup to my earlier post, I thought I would show how to modify the system.img the emulator is using.

This assumes that you are building Android and want to use some of the generated APKs inside the stock emulator.  That isn't the only scenario, but it's the one I am covering here.

First, we need to determine where the images are being loaded from. In this case my AVD is called "ics".

malachi@onyx:~/work/redo_system$ grep sysdir ~/.android/avd/ics.avd/config.ini
image.sysdir.2=system-images/android-14/armeabi-v7a/
image.sysdir.1=add-ons/addon-google_apis-google_inc_-14/images/armeabi-v7a/

Let's grab a local copy of those files
malachi@onyx:~/work/redo_system$ cp $ANDROID_HOME/add-ons/addon-google_apis-google_inc_-14/images/armeabi-v7a/* .

This time around, we are interested in the system.img. Let's unpack it.
malachi@onyx:~/work/redo_system$ mkdir unpacked
malachi@onyx:~/work/redo_system$ cd unpacked/
malachi@onyx:~/work/redo_system/unpacked$ unyaffs ../system.img
end of image

Replace a couple apps
malachi@onyx:~/work/redo_system/unpacked$ cd app
malachi@onyx:~/work/redo_system/unpacked/app$ cp ~/work/ics/out/target/product/SomeProduct/system/app/Contacts.apk .
malachi@onyx:~/work/redo_system/unpacked/app$ cp ~/work/ics/out/target/product/SomeProduct/system/app/ContactsProvider.apk .

Repack the system.img
malachi@onyx:~/work/redo_system/unpacked/app$ cd ../..
malachi@onyx:~/work/redo_system$ rm system.img
malachi@onyx:~/work/redo_system$ ~/work/ics/out/host/linux-x86/bin/mkyaffs2image unpacked system.img

Point our AVD to our new images
malachi@onyx:~/work/redo_system$ nano ~/.android/avd/ics.avd/config.ini
image.sysdir.2=system-images/android-14/armeabi-v7a/
image.sysdir.1=/home/malachi/work/redo_system/

The old userdata may not be compatible with your new apps. Make sure to use -wipe-data:

malachi@onyx:~/work/redo_system$ emulator -avd ics -show-kernel -scale 0.70 -memory 1024 -logcat 'dalvikvm:S,StrictMode:S,*:D' -partition-size 1024 -wipe-data

You are now running a slightly modified emulator...

source link: http://malsandroid.blogspot.co.uk/2012/03/modify-emulator-systemimg.html






Thursday, June 28, 2012

system.img pack/unpack

you could use unyaffs to obtain the contents of system.img
and then run mkyaffs2image to create a new image out of the remaining
subset of files. If the file system image is ext3/ext4 rather than
yaffs2 I suppose you could just mount the image file via a loop device
on just about any Linux machine.

[copied]Install Java, Android SDK, ADB, and Fastboot in Linux Ubuntu and Mint12

Original Source : http://rootzwiki.com/topic/20770-guideinstall-java-android-sdk-adb-and-fastboot-in-linux-ubuntu-and-mint12/

Thank you to the XDA original poster bloodychaos. I used some of his info/code and changed a few things to reflect new versions of Ubuntu/Android SDK.

OK I can confirm that the method for installing Android SDK and using ADB in the original post for Ubuntu 11.04 also works with the horrible looking, "unity" infested, Ubuntu 11.10 Oneiric Ocelot. There are some minor changes from the OP and how it will work with 11.10/11.04. Here are the steps I took to get ADB working like a charm. Again, all the credit goes to the original poster. I'm just reporting my experience using his method/advice:

***please make sure debugging is enabled on your phone: menu/settings/applications/development/check mark debugging to enable***

1-Install java by Sun(JDK). There are different ways of installing sun-java and one is mentioned in the original post. I've used my method often and it has worked for me quite well. Here it is:

method 1: I actually like this method best since you know what you are doing step by step.http://sites.google....ipsproject/java

This works in Linux Mint 12 also.

Method 2 (I'm still leaving this here but I strongly suggest you use method 1): If Synaptic is not acting weird (it does in 12.04 Beta), use this method. Since Ubuntu no loinger includes Synaptic, go to Ubuntu Software Center, search for it, check all the add-ons in the middle, apply the changes, once done, click install in the right hand corner. Once installed start the package manager (start typing synaptic in the dock's search) and click on it. Now click on settings/repositories. Click the "other software" tab and click ADD. Now in the APT line copy and paste this: ppa:ferramroberto/java

click add source and then add volume and close. When you are back in the Synaptic window, click reload. Once reloaded, in the quick filter field type java6. You will see some entries, you need to "right click" the box and choose mark for installation for 4 items: sun-java6-bin, sun-java6-jre, sun-java6-jdk, sun-java6-plugin. Click apply and now you should see the box next to those items as green. You are done with java.

2- Download and Install Android SDK (which has ADB included of course):

http://developer.and.../sdk/index.html

Click and download the Linux version. Go to your Download folder and “right” click the .tgz file and click extract here. Now you have a folder called android-sdk-linux. Cut it from this folder and paste it in the Home folder. Note that the most of the names have changed from the original post.

Fire up a terminal (search for terminal in the dock's search field) and change directory from Home (that terminal opens in) to android-sdk-linux/tools type:

cd android-sdk-linux/tools

( you can do it in one step like above or two steps, first cd into the android-sdk-linux then into tools)

Now update the sdk by typing:

./android update sdk

The update window and the sdk open up. By default, all platforms have been selected to be installed. This will take a very long time; so if you don't need all those platforms, only pick a few you need to install. I chose all and it took me a few hours. No harm to choose all but be warned, it takes for ever.

HTC and MOTO now want you to have a dev account. You can create one, it takes a few seconds for each. Once you enter your new login and password in the SDK update window once, you don't need to enter it for all their platforms.


3- make sure USB debugging box is checked on your phone, settings/applications/development. Now connect your phone. You DO NOT want to turn on USB storage and you should see the usb debugging connected message.

4- In the terminal type:

cd android-sdk-linux/platform-tools

to go to that folder. Now type:

./adb devices

If you see your device in something like this, you are done.

List of devices attached

HT12HS005115    device


But I doubt it. I've never seen it work that easily. You have to give permission to your phone. While still connected to your phone, in the terminal type lsusb to get a list of all usb devices. Usually the last one is your phone. I didn't know HTC stood for High Tech Computer Corp so it took me a few seconds to locate it. :) Now right down the 9 character (xxxx:xxxx) ID to the left of your phone.

In the terminal, type in cd then press enter to be at the ~$ prompt. Now type:

sudo gedit /etc/udev/rules.d/99-android.rules

to create a blank file and open it (you have to enter your root password every time you type sudo. You don't see anything being typed but it's there. If you are here reading this you already knew that though). In the file type (copy and paste of course):

SUBSYSTEM=="usb", ATTRS{idVendor}=="####:####", SYMLINK+="android_adb", MODE="0666" GROUP="plugdev"
TEST=="/var/run/ConsoleKit/database", \
RUN+="udev-acl --action=$env{action} --device=$env{DEVNAME}"

(thank you cainn24 for the typo correction)

now care fully replace the ####:#### with the 9 character you wrote down above. Save and exit.

Type:

sudo service udev restart

and press enter.

5- Now we need to test adb to see if it worked. In a terminal, type:

cd android-sdk-linux/platform-tools

to change to that directory. ADB is in there. Type in

./adb devices

If you see your device and it's serial number your done. If you don't (which I did not) stop and restart adb by using these commands while you are in that folder still:

./adb kill-server

./adb start-server

Now unplug your phone and replug it and tyoe:

./adb devices

You should now see your device and it's serial number.

6- To be able to use adb from any folder in the terminal and use it as a command (without the ./), do this: (creating a path)

In a terminal type: (it can be at any prompt)

sudo gedit ~/.bashrc

enter password and enter. A file opens up. You need to add the following at the end of the file: (again note that names have changed from the original post)

# Android tools
export PATH=${PATH}:~/android-sdk-linux/toolsexport PATH=${PATH}:~/android-sdk-linux/platform-tools

save and exit. Make sure you are not adding or omitting anything or you will get an error. You need to restart your computer, kill adb and restart adb as above, and unplug/re-plug your phone to complete this step. Now press cd and enter to be at ~$ prompt. Lets see if adb works without being in that folder: type:

adb devices

if you get the same device name and serial number you got when you were in the adb directory, you are done. You can now run adb from anywhere as a command. If you don't, unplug and re-plug the phone, restart the terminal and should work.

Fastboot
update 02-22-12: It seems like Google has included fastboot in the platform-tools folder now. Before doing anything check and see if it's there. If it is, all you need to do is test it. Go to the last paragraph marked by *** in this section to test fastboot.


Setting up fastboot in Ubuntu 11.10: Now that you have adb setup, it's pretty easy to setup fastboot. The source of my knowledge for this is http://wiki.cyanogen...m/wiki/Fastboot

You may run into a guide that would ask you to use fastboot to accomplish something. So it's nice to have it handy when needed but don't be going around using commands you know nothing about. It may mess up your device.

For fastboot to work, you have to have S-OFF and be in the bootloader (fastboot menu). Remember, Bootloader/fastboot is not the same as the recovery menu. Unlike adb, nothing happens if you have your phone booted normally, you have to be in the fastboot menu. Now go tohttp://koushikdutta.blurryfox.com/G1/ and download the right version (Linux of course). Extract the zipped file and rename it fastboot for ease of use. Cut and paste it into your android-sdk-linux/platform-tools folder from the above settings. Because you set your path above to be able to issue commands from both tools and platform-tools folders, you are done. I chose the platform-tools since Google has moved adb from the tools folder to this folder. I read somewhere that they by mistake omitted fastboot from the latest version of Androiod SDK.

***Now to test it, turn your phone off and boot into the bootloader manually (each phone has different combo keys for this) or fire up a terminal and type:

adb reboot-bootloader

now type:

fastboot devices 

and see if your device and serial number is recognized. 

[copied]Installing adb & fastboot ubuntu 11.10 for the Galaxy Nexus


with a new galaxy nexus and wanting to unlock the bootloader and root my phone and since I’ve got a fresh install of ubuntu 11.10 i needed to do a new install of adb. Here’s how I did it:
installing java (replace aptitude with apt-get if that’s what you use)
sudo aptitude install python-software-properties
sudo add-apt-repository ppa:ferramroberto/java
sudo aptitude update
sudo aptitude install sun-java6-jdk sun-java6-plugin
         

download the sdk here and extract to your home folder. Fire up a terminal and enter
android-sdk-linux/tools/android update sdk --no-ui

         
which will update the sdk (this might take a while as it downloads everything, remove the –no-ui to be selective).
In the meantime download http://dl.dropbox.com/u/3930957/fastboot (downloaded from xda) and copy the fastboot binary to your /android-sdk-linux/tools/ folder then run the following in a terminal:
chmod +x ~/android-sdk-linux/tools/fastboot
chmod +x ~/android-sdk-linux/platform-tools/adb
         
to make adb commands work anywhere do the following in the terminal (replace vi with your editor of choice):
sudo vi ~/.bashrc
         
and add the following to the bottom:
# Android tools
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
         
then we need to edit the usb rules to get the phone recognized in fastboot (we’re creating this file if it doesn’t exist already), in the terminal enter (replace vi with your editor of choice):
sudo vi /etc/udev/rules.d/70-android.rules
         
and add the following line (replace <username> with your username):
# fastboot protocol on maguro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0666", OWNER="<username>"
         
then execute the following in the terminal (which will reboot your computer):
sudo chmod a+rx /etc/udev/rules.d/70-android.rules
sudo reboot
         
then fire up a terminal and run ‘adb devices’  if you return an alphanumeric set on the left with device on the right the job’s a good un! (boot into the bootloader by powering off then  use vol up + vol down + power at the same time. Once in the bootloader execute ‘fastboot devices’ in the terminal to test bootloader works)
all this info gathered from the experts on xda-developers.com
Now off you go and unlock your bootloader and add root by using this guide:
enjoy!
edit: updated with some obsernations from airtonix
No related posts.

[copied]tutoriel: how using fastboot

Original Source: http://forum.geeksphone.com/index.php?topic=1981.0


i will explain how to use fastboot. fastboot is usefull if you want reflash original rom. if you have bootloop that can't be resolved in recovery( with wipe factory reset cache and reinstall cm no effect too on bootloop) the last remedy is fastboot.
but this tuto is for linux user because i haven't success to install nt-driver on xp or seven(maybe i'm a noob in windows  ;D )

 1) download platform-tools.zip it contain adb and fastboot. it is the simplified package from sdk android:
http://www.megaupload.com/?d=B320DBB2

2) dezip the package and copy adb and fastboot in /usr/bin (need to be root)
cp /path dezipped/adb /usr/bin
cp /path dezipped/fastboot /usr/bin

3)edit or create  if it don't exist : /etc/udev/rules.d/51-android.rules (need to be root)
you insert this line in:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="9025", MODE="0666"

give permission:
chmod a+r /etc/udev/rules.d/51-android.rules

4) reboot the pc

5)now plug your zero to see if your pc detect it and type:
adb devices
this command must return the number of the device. if it the case you are right you can continue this tuto.

6)download the original rom and dezip it:
http://www.geeksphone.com/zerohome/ZERO_FINAL_Stock_Rom-zero-AP-20110314.zip

7) now we will enter in fastboot mode on your zero, type:
adb reboot bootloader

the phone will reboot in an empty screen black.don't be surprised it's normal(on htc phone it's a white screen the fastboot mode)

8)to be sure fastboot command work type:
fastboot devices
if it detect the phone it return "? ? ? ? ? ? ? ?" 

9)we will erase the contents of the userdata partition and erase the cache partition:
fastboot erase userdata
fastboot erase cache

10)now we will flash the original rom, with the file dezipped ZERO_FINAL_Stock_Rom-zero-AP-20110314.zip:

fastboot flash /path in your pc dezipped zero final stock rom/boot.img
fastboot flash /path in your pc  dezipped zero final stock rom/recovery.img
fastboot flash /path in your pc  dezipped zero final stock rom/system.img

yesterday this last line to flash system.img give me an error but it's not important because with the boot+recovery it's sufficient to reinstall CM7 with the new recovery flashed and that's worked for me and resolve my bootloop problem.

i forget to try this command maybe can working, flash directly the stock rom without dezipped in one command:
fastboot update /path to your/ZERO_FINAL_Stock_Rom-zero-AP-20110314.zip 

10)for more information about fastboot you can see:
http://developer.htc.com/adp.html
http://android-dls.com/wiki/index.php?title=Fastboot

Tuesday, June 26, 2012

[solved]fatal: branch 'stable' has not been signed

Problem:

Get https://gerrit.googlesource.com/git-repo
error: The requested URL returned error: 403
error: The requested URL returned error: 403

fatal: branch 'stable' has not been signed

Solution: If you are not behind any network proxy, your git version must be too low. Update git.

see how to install git 1.7 on ubuntu 8.03


install git 1.7 on ubuntu 8.04LTS(hardy)

source link: http://islandlinux.org/howto/install-latest-git-version-ubuntu

I am in the process of migrating from Subversion to Git for all of my projects and needed a way to install the latest version of Git in Ubuntu. There are many excellent resources that I have combined in this howto. I will be installing Git from Launchpad.
The first step in installing the latest version of Git is to tell apt where and how to get Git. These instructions are for Ubuntu Hardy Heron 8.04 LTS and will also work on later versions. Note that since Ubuntu 9.10 you can use the "sudo add-apt-repository" method to add the latest version of Git to Ubuntu. Create "/etc/apt/sources.list.d/git.ppa.list" and add the following lines (note that you can skip the deb-src if you do not need the Git source):
To use this approach to install the latest Git for other versions of Ubuntu simply change "hardy" to the appropriate name (eg: lucid, karmic, jaunty, or intrepid).
Note that if you were to run "sudo apt-get update" you will get the following error:
W: GPG error: http://ppa.launchpad.net hardy Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E76E800643C34E6
W: You may want to run apt-get update to correct these problems
To remove this message Ubuntu must be told that the package repository can be trusted. Go to the Launchpad PPA for Smartlounge and click on the "Technical details about this PPA". Note the signing key; in this case it is listed as "1024R/643C34E6". Copy the last part of the key and run the following command:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 643C34E6
You should see the following message:
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --keyserver keyserver.ubuntu.com --recv-keys 643C34E6
gpg: requesting key 643C34E6 from hkp server keyserver.ubuntu.com
gpg: key 643C34E6: public key "Launchpad PPA for Smartlounge" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
And now you can install the latest version of Git for Ubuntu:
sudo apt-get update
sudo apt-get install git-core
Launchpad PPA for Smartlounge also maintains the following packages:
  • hamster-applet
  • kdiff3
  • kla
  • qgit
  • smlscripts-addon

Friday, June 15, 2012

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error change


In file included from external/gtest/src/gtest-all.cc:38:0:
external/gtest/src/../src/gtest-filepath.cc: In member function ‘bool testing::internal::FilePath::FileOrDirectoryExists() const’:
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_dev’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::__pad1’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::__st_ino’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_mode’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_nlink’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_uid’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_gid’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_rdev’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::__pad2’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_size’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_blksize’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_blocks’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_atim’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_mtim’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_ctim’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:180:28: warning: missing initializer for member ‘stat::st_ino’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc: In member function ‘bool testing::internal::FilePath::DirectoryExists() const’:
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_dev’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::__pad1’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::__st_ino’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_mode’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_nlink’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_uid’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_gid’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_rdev’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::__pad2’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_size’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_blksize’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_blocks’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_atim’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_mtim’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_ctim’ [-Wmissing-field-initializers]
external/gtest/src/../src/gtest-filepath.cc:208:28: warning: missing initializer for member ‘stat::st_ino’ [-Wmissing-field-initializers]
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1

external/gtest/include/gtest/internal/gtest-param-util.h
add
#include <cstddef>

Compile Android 4.0 on Ubuntu 11.10(2)

====== Ubuntu 64位编译 android 4.0源码 ====== 
参照Android官方文档构建编译环境 
http://source.android.com/source/initializing.html 

===== 错误1 ===== 

host C++: obbtool <= frameworks/base/tools/obbtool/Main.cpp 
:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror] 
:0:0: note: this is the location of the previous definition 
cc1plus: all warnings being treated as errors 

make: *** [out/host/linux-x86/obj/EXECUTABLES/obbtool_intermediates/Main.o] Error 1 

===== 错误2 ===== 

解决办法: 
build/core/combo/HOST_linux-x86.mk line 61: 

把: 
HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 
改为: 
HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 
参考:http://code.google.com/p/android/issues/detail?id=20795 

===== 错误3 ===== 

development/tools/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp:22:20: fatal error: GL/glx.h: No such file or directory 
compilation terminated. 
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libGLcommon_intermediates/GLDispatch.o] Error 1 

解决办法: 
sudo apt-get install libgl1-mesa-dev 

===== 错误4 ===== 
frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: error: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable] 
解决办法: 
vim frameworks/compile/slang/Android.mk 
把: 
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror 
改为: 
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter 
参考:http://code.google.com/p/android/issues/detail?id=22006#c0 
参考:http://groups.google.com/group/android-building/browse_thread/thread/0207abb98ed72304 

===== 错误5 ===== 
In file included from external/oprofile/libpp/arrange_profiles.cpp:24:0: 
external/oprofile/libpp/format_output.h:94:22: error: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive] 
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/liboprofile_pp_intermediates/arrange_profiles.o] Error 1 
解决办法: 
external/oprofile/libpp/format_output.h 

把: 
mutable counts_t & counts; 
改为: 
counts_t & counts; 

===== 错误6 ===== 
external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock' 
collect2: ld returned 1 exit status 
解决办法: 
vim external/llvm/llvm-host-build.mk 
LOCAL_LDLIBS := -lpthread -ldl 

采用以下解决办法没有成功 
vi external/llvm/lib/Support/Android.mk 
添加 
LOCAL_C_INCLUDES += system/core/include/cutils 
LOCAL_SHARED_LIBRARIES := libcutil 
(其中存在两个模块,两个都加上上面两句话吧) 
以及在Mutex.cpp文件中加上threads.h头文件的引入 
vi external/llvm/lib/Support/Mutex.cpp 
添加 
#include 
以及在Threading.cpp文件中加上threads.h头文件的引入 
vi external/llvm/lib/Support/Threading.cpp 
添加 
#include 
===== 错误7 ===== 
external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: error: ‘ptrdiff_t’ does not name a type 
解决办法: 
vim external/gtest/src/../include/gtest/internal/gtest-param-util.h 
#include <cstddef>
















1._FORTIFY_SOURCE”重定义 

build/core/combo/HOST_linux-x86.mk line 61: -HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 +HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 
修改build/core/combo/HOST_linux-x86.mk 61行,将 HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0 修改成 HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 

2.错误: reference ‘counts’ cannot be declared ‘mutable’ [-fpermissive] 
external/oprofile/libpp/format_output.h 

自己动手修改。去除mutable。 

3.external/gtest/src/../include/gtest/internal/gtest-param-util.h:122:11: 错误: ‘ptrdiff_t’不是一个类型名 
In file included from external/gtest/src/../include/gtest/gtest-param-test.h:157:0, 
                 from external/gtest/src/../include/gtest/gtest.h:69, 
                 from external/gtest/src/../src/gtest.cc:34, 
                 from external/gtest/src/gtest-all.cc:36: 

解决方法: 
$vim external/gtest/src/../include/gtest/internal/gtest-param-util.h 
#include <cstddef> 

4.host Executable: test-librsloader (out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader) 
host StaticLib: libui (out/host/linux-x86/obj/STATIC_LIBRARIES/libui_intermediates/libui.a) 
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Signals.o): In function `PrintStackTrace': 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Unix/Signals.inc:219: undefined reference to `dladdr' 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Unix/Signals.inc:231: undefined reference to `dladdr' 
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Threading.o): In function `llvm::llvm_execute_on_thread(void (*)(void*), void*, unsigned int)': 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Threading.cpp:96: undefined reference to `pthread_create' 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Threading.cpp:91: undefined reference to `pthread_attr_setstacksize' 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Threading.cpp:100: undefined reference to `pthread_join' 
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `MutexImpl': 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:69: undefined reference to `pthread_mutexattr_init' 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:75: undefined reference to `pthread_mutexattr_settype' 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:80: undefined reference to `pthread_mutexattr_setpshared' 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:89: undefined reference to `pthread_mutexattr_destroy' 
out/host/linux-x86/obj/STATIC_LIBRARIES/libLLVMSupport_intermediates/libLLVMSupport.a(Mutex.o): In function `llvm::sys::MutexImpl::tryacquire()': 
/home/shaocq/ics4.0.1/external/llvm/lib/Support/Mutex.cpp:143: undefined reference to `pthread_mutex_trylock' 
collect2: ld 返回 1 
make: *** [out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] 错误 1 
make: *** 正在等待未完成的任务.... 

解决方法: 
$vim external/llvm/llvm-host-build.mk 
LOCAL_LDLIBS := -lpthread -ldl 

5.collected 3100 test methods in 225 junit test classes 
target Strip: libchromium_net (out/target/product/generic/obj/lib/libchromium_net.so) 
target Java: LatinIME (out/target/common/obj/APPS/LatinIME_intermediates/classes) 
target Dex: Music 
target Strip: libandroid_runtime (out/target/product/generic/obj/lib/libandroid_runtime.so) 
host C++: llvm-rs-cc <= frameworks/compile/slang/slang_rs_export_foreach.cpp 
frameworks/compile/slang/slang_rs_export_foreach.cpp: 在静态成员函数‘static slang::RSExportForEach* slang::RSExportForEach::Create(slang::RSContext*, const clang::FunctionDecl*)’中: 
frameworks/compile/slang/slang_rs_export_foreach.cpp:247:23: 错误: variable ‘ParamName’ set but not used [-Werror=unused-but-set-variable] 
cc1plus:所有的警告都被当作是错误 

解决方法: 
$ vim frameworks/compile/slang/Android.mk 
#local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter -Werror 
local_cflags_for_slang := -Wno-sign-promo -Wall -Wno-unused-parameter 

6.external/mesa3d/src/glsl/linker.cpp:623:33: 警告:   ‘virtual ir_visitor_status remap_variables(ir_instruction*, gl_shader*, hash_table*)::remap_visitor::visit(ir_dereference_variable*)’所隐藏 [-Woverloaded-virtual] 
external/mesa3d/src/glsl/linker.cpp: 在函数‘void assign_varying_locations(gl_shader_program*, gl_shader*, gl_shader*)’中: 
external/mesa3d/src/glsl/linker.cpp:1394:49: 错误: expected primary-expression before ‘,’ token 
external/mesa3d/src/glsl/linker.cpp:1394:50: 错误: ‘varyings’在此作用域中尚未声明 
external/mesa3d/src/glsl/linker.cpp:1394:58: 错误: ‘offsetof’在此作用域中尚未声明 
external/mesa3d/src/glsl/linker.cpp:1395:48: 错误: expected primary-expression before ‘,’ token 
external/mesa3d/src/glsl/linker.cpp:1412:47: 错误: expected primary-expression before ‘,’ token 
external/mesa3d/src/glsl/linker.cpp:1412:48: 错误: ‘position’在此作用域中尚未声明 
external/mesa3d/src/glsl/linker.cpp:1414:47: 错误: expected primary-expression before ‘,’ token 
external/mesa3d/src/glsl/linker.cpp:1414:48: 错误: ‘pointSize’在此作用域中尚未声明 
external/mesa3d/src/glsl/linker.cpp:1424:47: 错误: expected primary-expression before ‘,’ token 
external/mesa3d/src/glsl/linker.cpp:1424:48: 错误: ‘position’在此作用域中尚未声明 
external/mesa3d/src/glsl/linker.cpp:1428:47: 错误: expected primary-expression before ‘,’ token 
external/mesa3d/src/glsl/linker.cpp:1428:48: 错误: ‘frontFacingPointCoord’在此作用域中尚未声明 
external/mesa3d/src/glsl/linker.cpp:1431:47: 错误: expected primary-expression before ‘,’ token 
external/mesa3d/src/glsl/linker.cpp:1431:48: 错误: ‘frontFacingPointCoord’在此作用域中尚未声明 
external/mesa3d/src/glsl/linker.cpp: 在函数‘void link_shaders(const gl_context*, gl_shader_program*)’中: 
external/mesa3d/src/glsl/linker.cpp:1734:49: 错误: expected primary-expression before ‘,’ token 
external/mesa3d/src/glsl/linker.cpp:1734:50: 错误: ‘fragColor’在此作用域中尚未声明 
external/mesa3d/src/glsl/linker.cpp:1734:59: 错误: ‘offsetof’在此作用域中尚未声明 
make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] 错误 1 
解决方法: 
vim external/mesa3d/src/glsl/linker.cpp 
添加: 
#include <cstddef>


Original Link: http://hcleon.iteye.com/blog/1461352