Building Froyo on Snow Leopard- Stepwise guide

I had posted a blog for “Building Froyo on Snow Leopard” previously and at that time I didn’t face any problems building Froyo but it looks like few make files have changed now. So I am writing this post as an update to my previous post.

Before starting on this, I would like to thank Tomas Isdal and andferno.

So I will note down all the steps involved in building Froyo on Snow leopard. You can refer android get source page for information. I have referred it for few of the steps involved in building android.

Step 1
Create a new partition that is a case-sensitive partition if you’re using a case-insensitive primary partition. You can refer to this for more info.

Step 2
You would also have to install Xcode 3.2 and 10.4 SDK. Xcode can be found in the installation disc. It can also be downloaded from Apple developers connection. Refer the attached image.

Xcode installation Option

Step 3
Install Macports. There are two ways of doing so.
i. Download the source from this link and untar the file. Run the following commands
./configure
make
sudo make install

ii. My preferred method is to download the DMG from here. I used MacPorts-1.8.2-10.6-SnowLeopard.dmg from the list.

Step 4
Make sure that /opt/local/bin is in your path before /usr/bin by running

echo $PATH

If you don’t see /opt/local/bin, edit $HOME/.bash_profile and add the line
export PATH=/opt/local/bin:$PATH
(or the equivalent for other shells) after any other PATH-related lines. To verify that your path is now correct, open a new terminal and run echo $PATH again.

Step 5
Get the following packages from port:
POSIXLY_CORRECT=1 sudo port install libsdl git-core gnupg

NOTE: Restart the terminal

Step 6
Set an appropriate per-process file descriptor limit. To do this, add the following lines to your .bash_profile file:
# set the number of open files to be 1024
ulimit -S -n 1024

Step 7
Now check out the Froyo Source code to the case-sensitive partition created in step 1, please refer android get source page for more information.

Step 8
Snow leopard doesn’t have Java 1.5, it has Java 1.6. Since Leopard has Java 1.5 this step can be skipped on Leopard. On Snow Leopard we have two options.

i. Changing Android make file to build with Java 1.6.
Open “build/core/main.mk” and search for “grep ‘[ “]1\.5” and change that “5″ with a “6″. You will find it repeated two times. This trick was suggested to me by andferno.

ii. Install Java 1.5 on Snow Leopard.

curl -o java.1.5.0-leopard.tar.gz http://www.cs.washington.edu/homes/isdal/snow_leopard_workaround/java.1.5.0-leopard.tar.gz
tar -xvzf java.1.5.0-leopard.tar.gz
sudo mv 1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0-leopard
cd /System/Library/Frameworks/JavaVM.framework/Versions/
sudo rm 1.5.0
sudo ln -s 1.5.0-leopard 1.5.0

We have to set Java preferences. You can either manually open “Java Preferences.app” or use terminal and type

open /Applications/Utilities/Java\ Preferences.app

Change the preference to as shown in the image below. You would have to drag and drop different Java version to change the preference.

Setting Java Preferences

NOTE: Restart the terminal

Building the source and resolving errors
Build the source.

make -j2

You might face the following error first.

host C++: emulator-elff <= external/qemu/elff/dwarf_cu.cc
In file included from external/qemu/qemu-common.h:15,
from external/qemu/elff/elf.h:22,
from external/qemu/elff/elf_defs.h:20,
from external/qemu/elff/dwarf_defs.h:22,
from external/qemu/elff/dwarf_die.h:20,
from external/qemu/elff/elf_file.h:20,
from external/qemu/elff/dwarf_cu.cc:20:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from external/qemu/elff/dwarf_die.h:21,
from external/qemu/elff/elf_file.h:20,
from external/qemu/elff/dwarf_cu.cc:20:
external/qemu/elff/elf_alloc.h: In static member function ‘static void* DwarfAllocBase::operator new(size_t)’:
external/qemu/elff/elf_alloc.h:156: warning: ‘operator new’ must not return NULL unless it is declared ‘throw()’ (or -fcheck-new is in effect)
make: *** [out/host/darwin-x86/obj/STATIC_LIBRARIES/emulator-elff_intermediates/elff/dwarf_cu.o] Error 1

To fix this error go to “external/qemu/” and open “Makefile.android” file and change the following line

iMY_CFLAGS += -mdynamic-no-pic

to

MY_CFLAGS += -mdynamic-no-pic -I /Developer/usr/lib/gcc/i686-apple-darwin10/4.0.1/include/

Continue with the build process again and you are likely to come across following errors

In file included from external/v8/src/macro-assembler.h:87,
from external/v8/src/jsregexp.h:31,
from external/v8/src/ast.h:33,
from external/v8/src/compiler.h:31,
from external/v8/src/api.cc:33:
external/v8/src/arm/assembler-arm-inl.h: In constructor ‘v8::internal::Operand::Operand(const char*)’:
external/v8/src/arm/assembler-arm-inl.h:165: error: cast from ‘const char*’ to ‘int32_t’ loses precision
external/v8/src/arm/assembler-arm-inl.h: In constructor ‘v8::internal::Operand::Operand(const v8::internal::ExternalReference&)’:
external/v8/src/arm/assembler-arm-inl.h:172: error: cast from ‘v8::internal::byte*’ to ‘int32_t’ loses precision
In file included from external/v8/src/macro-assembler.h:87,
from external/v8/src/ic-inl.h:33,
from external/v8/src/assembler.cc:39:
external/v8/src/arm/assembler-arm-inl.h: In constructor ‘v8::internal::Operand::Operand(const char*)’:
external/v8/src/arm/assembler-arm-inl.h:165: error: cast from ‘const char*’ to ‘int32_t’ loses precision
external/v8/src/arm/assembler-arm-inl.h: In constructor ‘v8::internal::Operand::Operand(const v8::internal::ExternalReference&)’:
external/v8/src/arm/assembler-arm-inl.h:172: error: cast from ‘v8::internal::byte*’ to ‘int32_t’ loses precision

This may not be the only precision error you may get. If you come across any errors like “error: cast from ‘abc’ to ‘xyz’ loses precision

Do the following. Open “build/core/config.mk” file and search for the following text.

PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true)

and replace the above text with following text.

PREBUILT_IS_PRESENT := $(if $(wildcard prebuilt/Android.mk),true)

ifeq ($(HOST_OS),darwin)
HOST_GLOBAL_CFLAGS += -arch i386
HOST_GLOBAL_CPPFLAGS += -arch i386
HOST_GLOBAL_LDFLAGS += -arch i386
endif

Again continue the build process and you are likely to come across following error

host C: acp <= build/tools/acp/acp.c
host C++: libhost <= build/libs/host/pseudolocalize.cpp
host C: libhost <= build/libs/host/CopyFile.c
build/libs/host/CopyFile.c: In function ‘copyFileContents’:
build/libs/host/CopyFile.c:124: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘ssize_t’
build/libs/host/CopyFile.c:124: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
host StaticLib: libhost (out/host/darwin-x86/obj/STATIC_LIBRARIES/libhost_intermediates/libhost.a)
ar crs out/host/darwin-x86/obj/STATIC_LIBRARIES/libhost_intermediates/libhost.a out/host/darwin-x86/obj/STATIC_LIBRARIES/libhost_intermediates/pseudolocalize.o out/host/darwin-x86/obj/STATIC_LIBRARIES/libhost_intermediates/CopyFile.o
host Executable: acp (out/host/darwin-x86/obj/EXECUTABLES/acp_intermediates/acp)
ld: warning: in out/host/darwin-x86/obj/EXECUTABLES/acp_intermediates/acp.o, file is not of required architecture
ld: warning: in out/host/darwin-x86/obj/STATIC_LIBRARIES/libhost_intermediates/libhost.a, file is not of required architecture
Undefined symbols:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [out/host/darwin-x86/obj/EXECUTABLES/acp_intermediates/acp] Error 1

To fix this error open “darwin-x86.mk” present in “build/core/combo/” and find the following strings.

$(HOST_CXX) \
-dynamiclib -single_module -read_only_relocs suppress \
$(HOST_GLOBAL_LD_DIRS) \

and add the following strings after the above string.

$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(HOST_GLOBAL_LDFLAGS) \
) \

Find the following strings

$(HOST_CXX) \
-Wl,-dynamic -headerpad_max_install_names \
$(HOST_GLOBAL_LD_DIRS) \
$(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \

and add the following strings after the above string.

$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(HOST_GLOBAL_LDFLAGS) \
) \

Start the build again and watch it fly. Feel free to revert back in-case of any queries.

Advertisements

19 thoughts on “Building Froyo on Snow Leopard- Stepwise guide

  1. Pingback: Building Eclair on Snow Leopard « Vishvesh's Blog

  2. Pingback: Building Froyo on Snow Leopard « Vishvesh's Blog

  3. host SharedLib: libneo_util (out/host/darwin-x86/obj/lib/libneo_util.dylib)
    host Executable: acp (out/host/darwin-x86/obj/EXECUTABLES/acp_intermediates/acp)
    /bin/bash: out/host/darwin-x86/obj/SHARED_LIBRARIES/libneo_util_intermediates/neo_err.o: Permission denied
    make: *** [out/host/darwin-x86/obj/lib/libneo_util.dylib] Error 126
    make: *** Waiting for unfinished jobs….
    arch: Can’t find i386 in PATH
    make: [out/host/darwin-x86/obj/EXECUTABLES/acp_intermediates/acp] Error 1 (ignored)
    true

  4. Trying to build android src.

    Followed all instructions from source.android.com

    I know it says Snow-Leopard is not supported, but have googled and have found many guys are able to build android src

    So , installed Macports 1.9.1 dmg file and repo sync the code Ran ‘make’ , got some kind of error that said “object_error_freed”

    In some post it was pointed out that it mainly happened due ‘Newest version of Macports’

    So completely uninstalled macports and installed macport 1.9.0

    Now in this step : POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg

    i get error as :

    ” —> Dependencies to be installed: xorg-libXext xorg-libX11 xorg-libxcb python26 db46 gdbm openssl zlib readline sqlite3 xorg-libpthread-stubs xorg-xcb-proto libxml2 xorg-util-macros xorg-xcmiscproto xorg-xextproto xorg-xf86bigfontproto xorg-xtrans xorg-libXrandr xorg-randrproto xrender xorg-renderproto

    —> Building db46 Error: Target org.macports.build returned: shell command failed

    Log for db46 is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_databases_db46/main.log

    Error: The following dependencies failed to build: xorg-libXext xorg-libX11 xorg-libxcb python26 db46 gdbm openssl zlib readline sqlite3 xorg-libpthread-stubs xorg-xcb-proto libxml2 xorg-util-macros xorg-xcmiscproto xorg-xextproto xorg-xf86bigfontproto xorg-xtrans xorg-libXrandr xorg-randrproto xrender xorg-renderproto

    Error: Status 1 encountered during processing.

    To report a bug, see http://guide.macports.org/#project.tickets

    I am just unable to understand what should be the next step.

    Where to debug ?

    • Completely uninstall the version of Macports you have installed. Install “MacPorts-1.8.2-10.6-SnowLeopard.dmg”. I have put up the link in this post. For some reason I had problems with latest versions of Macports.

      Important : After Installing MacPorts-1.8.2, don’t upgrade your macport directly do the step 5 of this post.

      This should solve your problem. Feel free to revert back if you have any issues.

      • I had done that….though the same problem…after uninstalling tried installing again with 1.8.2,1.9.0 and then with 1.9.1…same result…db46 problem

        I just dragged opt folder to thrash…

        and also

        used following 2 commands to uninstall macports

        (1) sudo port -f uninstall installed

        (2) sudo rm -rf \
        /opt/local \
        /Applications/DarwinPorts \
        /Applications/MacPorts \
        /Library/LaunchDaemons/org.macports.* \
        /Library/Receipts/DarwinPorts*.pkg \
        /Library/Receipts/MacPorts*.pkg \
        /Library/StartupItems/DarwinPortsStartup \
        /Library/Tcl/darwinports1.0 \
        /Library/Tcl/macports1.0 \
        ~/.macports

        The above 2 commands were obtained from http://guide.macports.org/

        Still Stuck…..

        Any feedback ?

        Thanks

  5. Got:
    v8::internal::ScopeInfo::ScopeInfo(v8::internal::Scope*)in scopeinfo.o
    v8::internal::ScopeInfo::ScopeInfo(v8::internal::Scope*)in scopeinfo.o
    v8::internal::ScopeInfo::ScopeInfo(v8::internal::Scope*)in scopeinfo.o
    v8::internal::List::Resize(int)in scopeinfo.o
    v8::internal::List::Resize(int)in scopeinfo.o
    v8::internal::List<v8::internal::Handle, v8::internal::FreeStoreAllocationPolicy>::Resize(int)in scopeinfo.o
    v8::internal::Allocator::New(unsigned long)in scopes.o
    v8::internal::List::Resize(int)in scopes.o
    v8::internal::ExternalReferenceEncoder::ExternalReferenceEncoder()in serialize.o
    v8::internal::ExternalReferenceDecoder::ExternalReferenceDecoder()in serialize.o
    v8::internal::ExternalReferenceEncoder::NameOfAddress(unsigned char*) constin serialize.o
    v8::internal::ExternalReferenceEncoder::Encode(unsigned char*) constin serialize.o
    v8::internal::List::Resize(int)in serialize.o
    v8::internal::List::Resize(int)in serialize.o
    v8::internal::List::Resize(int)in spaces.o
    v8::internal::List::Resize(int)in spaces.o
    v8::internal::List::Resize(int)in spaces.o
    __static_initialization_and_destruction_0(int, int)in spaces.o
    __static_initialization_and_destruction_0(int, int)in spaces.o
    v8::internal::List::Resize(int)in virtual-frame.o
    v8::internal::Zone::NewExpand(int)in zone.o
    v8::internal::CodeGenerator::CodeGenerator(v8::internal::MacroAssembler*)in codegen-arm.o
    v8::internal::CodeGenerator::VisitTryCatchStatement(v8::internal::TryCatchStatement*)in codegen-arm.o
    v8::internal::CodeGenerator::VisitTryFinallyStatement(v8::internal::TryFinallyStatement*)in codegen-arm.o
    v8::internal::List::Resize(int)in codegen-arm.o
    v8::internal::List::Resize(int)in fast-codegen-arm.o
    v8::internal::RegExpMacroAssemblerARM::RegExpMacroAssemblerARM(v8::internal::NativeRegExpMacroAssembler::Mode, int)in regexp-macro-assembler-arm.o
    v8::internal::List::Resize(int)in mksnapshot.o
    v8::internal::ThreadHandle::ThreadHandle(v8::internal::ThreadHandle::Kind)in platform-macos.o
    “___android_log_vprint”, referenced from:
    v8::internal::OS::VPrintError(char const*, char*)in platform-posix.o
    v8::internal::OS::VPrint(char const*, char*)in platform-posix.o
    “v8::internal::Accessors::ArrayLength”, referenced from:
    __ZN2v88internal9Accessors11ArrayLengthE$non_lazy_ptr in bootstrapper.o
    __ZN2v88internal9Accessors11ArrayLengthE$non_lazy_ptr in serialize.o
    (maybe you meant: __ZN2v88internal9Accessors11ArrayLengthE$non_lazy_ptr)
    “v8::internal::Accessors::ScriptContextData”, referenced from:
    __ZN2v88internal9Accessors17ScriptContextDataE$non_lazy_ptr in bootstrapper.o
    __ZN2v88internal9Accessors17ScriptContextDataE$non_lazy_ptr in serialize.o
    (maybe you meant: __ZN2v88internal9Accessors17ScriptContextDataE$non_lazy_ptr)
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [out/host/darwin-x86/obj/EXECUTABLES/mksnapshot_intermediates/mksnapshot] Error 1

    Ideas on this one?

  6. I’m trying to do a QSD build so some of the error is different but the end point is the same problem i think. Thanks for the guide so far!

    ============================================
    PLATFORM_VERSION_CODENAME=REL
    PLATFORM_VERSION=2.2.1
    TARGET_PRODUCT=qsd8250_surf
    TARGET_BUILD_VARIANT=eng
    TARGET_SIMULATOR=false
    TARGET_BUILD_TYPE=release
    TARGET_BUILD_APPS=
    TARGET_ARCH=arm
    HOST_ARCH=x86
    HOST_OS=darwin
    HOST_BUILD_TYPE=release
    BUILD_ID=FRG83
    ============================================
    build/core/base_rules.mk:108: user tag on app Stk at packages/apps/Stk – add your app to core.mk instead
    build/core/base_rules.mk:69: unusual tags development eng user on TSCalibration at packages/apps/TSCalibration
    build/core/base_rules.mk:108: user tag on app TSCalibration at packages/apps/TSCalibration – add your app to core.mk instead
    build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/qsd8250_surf/obj/include/libpv/getactualaacconfig.h’
    build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/qsd8250_surf/obj/include/libpv/getactualaacconfig.h’
    build/core/base_rules.mk:69: unusual tags none on e2fsck_static at external/e2fsprogs/e2fsck
    build/core/base_rules.mk:69: unusual tags none on mke2fs_static at external/e2fsprogs/misc
    build/core/base_rules.mk:69: unusual tags none on tune2fs_static at external/e2fsprogs/misc
    build/core/base_rules.mk:69: unusual tags systembuilder on badblocks at external/e2fsprogs/misc
    build/core/base_rules.mk:108: user tag on app QualcommSoftAP at packages/apps/QualcommSoftAP – add your app to core.mk instead
    No private recovery resources for TARGET_DEVICE qsd8250_surf
    Copying: out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes-full-debug.jar
    make -C kernel O=../out/target/product/qsd8250_surf/obj/KERNEL_OBJ ARCH=arm CROSS_COMPILE=arm-eabi- qsd8650-perf_defconfig
    target Prelink: liblog (out/target/product/qsd8250_surf/symbols/system/lib/liblog.so)
    libelfcopy: Warning: Range lists in .debug_info section aren’t in ascending order!
    target Prelink: libexpat (out/target/product/qsd8250_surf/symbols/system/lib/libexpat.so)
    libelfcopy: Warning: Range lists in .debug_info section aren’t in ascending order!
    libelfcopy: Warning: Range lists in .debug_ranges section start at 0x7a8
    target Prelink: libz (out/target/product/qsd8250_surf/symbols/system/lib/libz.so)
    libelfcopy: Warning: Range lists in .debug_info section aren’t in ascending order!
    target Non-prelinked: libicudata-us (out/target/product/qsd8250_surf/symbols/system/lib/libicudata.so)
    GEN /Volumes/bigandroid/out/target/product/qsd8250_surf/obj/KERNEL_OBJ/Makefile
    host Executable: mksnapshot (out/host/darwin-x86/obj/EXECUTABLES/mksnapshot_intermediates/mksnapshot)
    ld: warning: in out/host/darwin-x86/obj/STATIC_LIBRARIES/liblog_intermediates/liblog.a, file was built for unsupported file format which is not the architecture being linked (i386)
    Undefined symbols:
    “___android_log_vprint”, referenced from:
    v8::internal::OS::VPrintError(char const*, char*)in platform-posix.o
    v8::internal::OS::VPrint(char const*, char*)in platform-posix.o
    v8::internal::OS::Print(char const*, …)in platform-posix.o
    v8::internal::OS::PrintError(char const*, …)in platform-posix.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [out/host/darwin-x86/obj/EXECUTABLES/mksnapshot_intermediates/mksnapshot] Error 1
    make: *** Waiting for unfinished jobs….
    drivers/usb/gadget/Kconfig:861:warning: defaults for choice values not supported
    drivers/usb/gadget/Kconfig:1065:warning: defaults for choice values not supported
    #
    # configuration written to .config
    #

    • I haven’t been able to make time to work on it yet. Will it give it a shot over the weekend and hope I would be able to come up with a solution. 🙂

  7. Could someone PLEASE help me with this error:

    ===========================================
    PLATFORM_VERSION_CODENAME=REL
    PLATFORM_VERSION=2.2.1
    TARGET_PRODUCT=generic
    TARGET_BUILD_VARIANT=eng
    TARGET_SIMULATOR=
    TARGET_BUILD_TYPE=release
    TARGET_BUILD_APPS=
    TARGET_ARCH=arm
    HOST_ARCH=x86
    HOST_OS=darwin
    HOST_BUILD_TYPE=release
    BUILD_ID=MASTER
    ============================================
    Docs droiddoc: out/target/common/docs/api-stubs
    target Strip: liblog (out/target/product/generic/obj/lib/liblog.so)
    target Strip: libexpat (out/target/product/generic/obj/lib/libexpat.so)
    target Strip: libz (out/target/product/generic/obj/lib/libz.so)
    target Strip: libicudata-us (out/target/product/generic/obj/lib/libicudata.so)
    Install: out/target/product/generic/system/lib/liblog.so
    Install: out/target/product/generic/system/lib/libexpat.so
    Install: out/target/product/generic/system/lib/libz.so
    Install: out/target/product/generic/system/lib/libicudata.so
    host Executable: mksnapshot (out/host/darwin-x86/obj/EXECUTABLES/mksnapshot_intermediates/mksnapshot)
    Undefined symbols:
    “_main”, referenced from:
    start in crt1.10.6.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [out/host/darwin-x86/obj/EXECUTABLES/mksnapshot_intermediates/mksnapshot] Error 1
    make: *** Waiting for unfinished jobs…

      • you know what, i’m not so sure anymore…
        anyway this is what i get:


        target Prelink: libdl (out/target/product/generic/symbols/system/lib/libdl.so)
        host Executable: mksnapshot (out/host/darwin-x86/obj/EXECUTABLES/mksnapshot_intermediates/mksnapshot)
        host C: mkyaffs2image <= external/yaffs2/yaffs2/utils/mkyaffs2image.c
        Undefined symbols:
        "_main", referenced from:
        start in crt1.10.6.o
        ld: symbol(s) not found
        collect2: ld returned 1 exit status
        make: *** [out/host/darwin-x86/obj/EXECUTABLES/mksnapshot_intermediates/mksnapshot] Error 1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s