element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
RIoTboard
  • Products
  • Dev Tools
  • Single-Board Computers
  • RIoTboard
  • More
  • Cancel
RIoTboard
Blog Building Android from Source
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join RIoTboard to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: radiatortwo
  • Date Created: 17 May 2014 5:14 PM Date Created
  • Views 4197 views
  • Likes 1 like
  • Comments 28 comments
  • android
  • environment
  • build
  • riotboard
Related
Recommended

Building Android from Source

radiatortwo
radiatortwo
17 May 2014

Since there´s only a small description on how to build Android from the sources and nothing about setting up the build environment, I am going to show you how to setup the build environment to compile Android for the RIoTBoard yourself.

 

I always work with Debian so the system we´ll be using is Debian 7.5. And it has to be the 64 bit version.

There is a chance this also works with Ubuntu 12.04 and above. But no guarantee to that.

 

It doesn´t matter if you use a virtual machine or a real host.

But this whole procedure will take some time depending on the speed of your system and your internet connection.

Also you´ll need a lot of space. At least 30 GB only for the sources plus some extra space of course.

Plus if you want to use the Cache to compile faster, you´ll need 50 to 100 GB extra space.

Also you need enough RAM. Recommended are 16 GB of RAM. But if your SWAP partition is big enough it should work anyway.

Just takes a bit longer.

 

I am using a server with a 4 Core Xeon E3 at 3.2GHz 32GB RAM and a GBit internet connection.

And it took me a few hours to get to the compiled image in the end.

 

But enough with that. Let´s grab a pot of coffee get in the terminal and start with the preparation.

 

First thing always before doing anything:

(As you see I assume you´re root.)

 

apt-get update
apt-get upgrade
apt-get dist-upgrade

 

Because we´ll need some stuff that´s compiled for i386 (no worries it works under 64bit)

Do the following:

 

dpkg --add-architecture i386
apt-get update

 

Now let´s install everything we need in this order.

 

apt-get install git-core gnupg flex bison python original-awk gawk p7zip-full gperf squashfs-tools build-essential zip curl pngcrush schedtool uboot-mkimage

apt-get install libsdl1.2-dev libesd0-dev libwxgtk2.8-dev zlib1g-dev

apt-get install lib32z1-dev ia32-libs lib32readline-gplv2-dev

apt-get install libc6-dev x11proto-core-dev libgl1-mesa-dev mingw32 tofrodos python-markdown libxml2-utils

apt-get install uuid-dev liblz-dev liblzo2-2 liblzo2-dev g++-multilib gcc-multilib

apt-get install libncurses5-dev:i386 libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 xsltproc zlib1g-dev:i386

ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

 

Now that was the first part and already took a while.

Only thing we need to install additionally is a JDK.

We need a JDK with version 6. Since the old JDK 6 is not freely available anymore (Thank you for that Oracle) we can only use OpenJDK 6.

 

apt-get install openjdk-6-jdk

 

If everything went through without problems we need to get the source code for Android.

To get it we need a little tool called repo.

This tool downloads all the stuff from all the different repos and puts it together in one folder.

 

So let´s download repo and put it in place so we can use it.

(I like to use the folder "/usr/src". But you can change that as you like.)

 

cd /usr/src
wget https://raw.github.com/android/tools_repo/stable/repo
mv repo /bin/repo
chmod 0755 /bin/repo

 

I know the manual says to use it temporary. But i don´t like stuff like that.

Then everytime you start a new session you have to put it in place again.

Like this it´s always availabe.

 

Now create a folder in which the whole Source is being downloaded.

 

mkdir riot_source
cd riot_source

 

Init the repo within that folder and start syncing it.

 

repo init --repo-url=git://github.com/android/tools_repo.git -u git://github.com/embest-tech/imx-manifest.git -m embest_android_jb4.3_1.0.0
repo sync -j16

 

With the parameter -j16 you tell repo to use 16 Threads.

If your Internet connection is fast enough this can speed it up a lot.

With a slower connection you should use something lower like 8 or 4 Threads.

 

Now that was part 2 and most likely the longest part of the whole procedure.

Grab another pot of coffee and let´s go on.

 

Because we don´t have Oracle JDK6 but OpenJDK6 and the makefile will stop with OpenJDK, we need to change the core makefile.

 

nano build/core/main.mk

 

Search for a block like this around line 142.

It´s easy to spot, because it misspells current...

image

You can either comment/remove that whole block.

Or just comment/remove the line "$(error stop)".

Then save that file and go on.

 

Next we will change a file to get a bit more permissions on the shell.

 

nano system/core/rootdir/init.rc

 

Search around line 417 for this.

 

service console /system/bin/sh
    class core
    console
    disabled
    user shell
    group log

 

And change it to this.

 

service console /system/bin/sh
    class core
    console
    disabled
    user root
    group root

 

Now we´re almost ready to compile.

 

First build up the environment.

 

. build/envsetup.sh

 

(I´ve seen something like "source build/envsetup.sh". But that will most likely not work.)

 

Then call lunch. (Everything in Android has to do with something to eat. Getting hungry here...)

 

lunch

 

And you get a list like this.

image

You see two entries for the RIoTBoard.

One with -eng and one with -user.

Here´s the explanation for that.

image

Of course we want -eng. So we type in 23 and press Enter.

If you´re then greeted with this, you´re ready to compile.

image

 

The next thing is optional. It´s used to speed up the compiling process, by using a cache on your hdd.

But consider this needs at least 50GB of free space in that cache folder.

So here is how to do it still being inthe folder "/usr/src/riot_source".

 

mkdir /usr/src/cache
export USE_CCACHE=1
export CCACHE_DIR=/usr/src/cache
prebuilts/misc/linux-x86/ccache/ccache -M 50G

 

This defines the environment variables so the cache is used. Stored inside "/usr/src/cache" and has a maximum size of 50GB.

It needs at least 50 GB of free space. Maximum is 100GB. (If you have that much free.)

 

Protip:

If you want to determine the location in which the image files are created.

Do the following before compiling.

 

export OUT_DIR_COMMON_BASE=<path-to-your-out-directory>

 

And now let´s compile.

Change the parameter -j8 to the count of your CPUs. Or a little bit more than that to get the CPU a little bit sweating.

But then it will compile a bit faster.

I chose 8.

2 threads for each core.

 

make -j8

 

So after it went hopefully through without errors.

You´ll find the image files in the folder "out/target/product/RIoTboard_6solo".

(Or the path you specified in "OUT_DIR_COMMON_BASE")

 

You´ll need these files.

 

boot.img

recovery.img

system.img

u-boot-mx6solo_RIoTboard_android_config.bin

 

These files are now ready to flash them on your RIoTBoard.

 

Hope this wasn´t too much for you and good luck.

 

image

  • Sign in to reply

Top Comments

  • radiatortwo
    radiatortwo over 11 years ago +1
    Since there are some problems with the repo init. Try this. Remove the folder (rm -rf folder) in which you want to create the repo and create it again. Then DON´T copy and paste it from here but type it…
  • stmorgan
    stmorgan over 8 years ago in reply to salih.mutlu@gmail.com

    If you are still interested in building Jelly Bean 4.3, see the MANUALLY APPLY GITHUB REVERSION section of this post:

     

    RIoTboard - Android Jelly Bean Build on openSUSE 13.2 x86_64

     

    Good luck!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • salih.mutlu@gmail.com
    salih.mutlu@gmail.com over 8 years ago in reply to stmorgan

    Actually, I was trying to build both jelly bean and kitkat, and had an intention to go on with whichever workes. Kitkat worked image, so, I will not deal with jelly bean. thanks anyway..

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • stmorgan
    stmorgan over 8 years ago in reply to salih.mutlu@gmail.com

    This issue is a duplicate of that reported here:

     

    Unable to do initial 'make' on Jelly Bean (4.3)

     

    This thread suggests a workaround, but it may not be acceptable depending on what you are trying to do.

     

    Are you trying to build Jelly Bean (4.3) or KitKat (4.4)?

     

    The problem might be due to a flawed implementation of Ethernet UI support in Jelly Bean (4.3) as described here:

     

    https://community.nxp.com/docs/DOC-93626

     

    Since Embest provided functional eMMC/SD card images for Jelly Bean (4.3) on RIoTboard, I'm guessing that they ran into this as well.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • salih.mutlu@gmail.com
    salih.mutlu@gmail.com over 8 years ago

    Hi,

    I am trying to follow the instructions, but I've ended up with following error: (trying on a debian 7.5 live virtualbox)

     

    ...

    Note: frameworks/base/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java uses or overrides a deprecated API.

    Note: Recompile with -Xlint:deprecation for details.

    Note: packages/providers/CalendarProvider/src/com/android/providers/calendar/CalendarDatabaseHelper.java uses or overrides a deprecated API.

    Note: Recompile with -Xlint:deprecation for details.

    Note: packages/providers/CalendarProvider/src/com/android/providers/calendar/CalendarProvider2.java uses unchecked or unsafe operations.

    Note: Recompile with -Xlint:unchecked for details.

    target Java: DownloadProviderUi (out/target/common/obj/APPS/DownloadProviderUi_intermediates/classes)

    target Java: Ethernet (out/target/common/obj/APPS/Ethernet_intermediates/classes)

    target Java: com.android.location.provider (out/target/common/obj/JAVA_LIBRARIES/com.android.location.provider_intermediates/classes)

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:25: cannot find symbol

    symbol  : class scanResult

    location: class android.net.EthernetDataTracker

    import android.net.EthernetDataTracker.scanResult;

                                          ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:26: cannot find symbol

    symbol  : class connectResult

    location: class android.net.EthernetDataTracker

    import android.net.EthernetDataTracker.connectResult;

                                          ^

    Note: Some input files use or override a deprecated API.

    Note: Recompile with -Xlint:deprecation for details.

    packages/apps/Ethernet/src/android/net/ethernet/EthernetMonitor.java:57: cannot find symbol

    symbol  : method setHandler(android.net.ethernet.EthernetMonitor.NetStateHandler)

    location: class android.net.EthernetDataTracker

            mDataTracker.setHandler(sInstance);

                        ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:198: cannot find symbol

    symbol  : method getEthernetCarrierState(java.lang.String)

    location: class android.net.EthernetDataTracker

            return mDataTracker.getEthernetCarrierState(iface);

                               ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:239: cannot find symbol

    symbol  : method configureIfc(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,boolean)

    location: class android.net.EthernetDataTracker

      mDataTracker.configureIfc(m.getIfName(),

                 ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:256: cannot find symbol

    symbol  : method configureIfc(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,boolean)

    location: class android.net.EthernetDataTracker

      isOK = mDataTracker.configureIfc(m.getIfName(),

                        ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:272: cannot find symbol

    symbol  : method setUserFlag(boolean)

    location: class android.net.EthernetDataTracker

      mDataTracker.setUserFlag(flag);

                 ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:347: cannot find symbol

    symbol  : class scanResult

    location: class android.net.ethernet.EthernetStateTracker

      scanResult sR;

      ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:348: cannot find symbol

    symbol  : class connectResult

    location: class android.net.ethernet.EthernetStateTracker

      connectResult cR;

      ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:353: cannot find symbol

    symbol  : variable ETHER_MSG_ADD_INTERFACE

    location: class android.net.EthernetDataTracker

                case EthernetDataTracker.ETHER_MSG_ADD_INTERFACE:

                                        ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:354: cannot find symbol

    symbol  : class scanResult

    location: class android.net.ethernet.EthernetStateTracker

      sR = (scanResult)msg.obj;

           ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:364: cannot find symbol

    symbol  : variable ETHER_MSG_INTERFACE_STATUS_CHANGE

    location: class android.net.EthernetDataTracker

      case EthernetDataTracker.ETHER_MSG_INTERFACE_STATUS_CHANGE:

                             ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:365: cannot find symbol

    symbol  : class scanResult

    location: class android.net.ethernet.EthernetStateTracker

      sR = (scanResult)msg.obj;

           ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:374: cannot find symbol

    symbol  : variable ETHER_MSG_INTERFACE_STATUS_CHANGE

    location: class android.net.EthernetDataTracker

      sendMessage(EthernetDataTracker.ETHER_MSG_INTERFACE_STATUS_CHANGE, sR.iFace);

                                    ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:379: cannot find symbol

    symbol  : variable ETHER_MSG_CONNECTED_SUCCESS

    location: class android.net.EthernetDataTracker

      case EthernetDataTracker.ETHER_MSG_CONNECTED_SUCCESS:

                             ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:380: cannot find symbol

    symbol  : class connectResult

    location: class android.net.ethernet.EthernetStateTracker

      cR = (connectResult)msg.obj;

           ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:391: cannot find symbol

    symbol  : variable ETHER_MSG_CONNECTED_SUCCESS

    location: class android.net.EthernetDataTracker

      sendMessage(EthernetDataTracker.ETHER_MSG_CONNECTED_SUCCESS, cR.iFace);

                                    ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:396: cannot find symbol

    symbol  : variable ETHER_MSG_CONNECTED_FAILED

    location: class android.net.EthernetDataTracker

      case EthernetDataTracker.ETHER_MSG_CONNECTED_FAILED:

                             ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:397: cannot find symbol

    symbol  : class connectResult

    location: class android.net.ethernet.EthernetStateTracker

      cR = (connectResult)msg.obj;

           ^

    packages/apps/Ethernet/src/android/net/ethernet/EthernetStateTracker.java:407: cannot find symbol

    symbol  : variable ETHER_MSG_CONNECTED_FAILED

    location: class android.net.EthernetDataTracker

      sendMessage(EthernetDataTracker.ETHER_MSG_CONNECTED_FAILED, cR.iFace);

                                    ^

    packages/apps/Ethernet/src/android/net/server/EthernetService.java:63: cannot find symbol

    Note: packages/providers/DownloadProvider/src/com/android/providers/downloads/StorageManager.java uses or overrides a deprecated API.

    Note: Recompile with -Xlint:deprecation for details.

    symbol  : method clearConnections()

    location: class android.net.EthernetDataTracker

      mDataTracker.clearConnections();

                 ^

    packages/apps/Ethernet/src/android/net/server/EthernetService.java:64: cannot find symbol

    symbol  : method scanInterface()

    location: class android.net.EthernetDataTracker

      mDataTracker.scanInterface();

                 ^

    target R.java/Manifest.java: Gallery2 (out/target/common/obj/APPS/Gallery2_intermediates/src/R.stamp)

    Note: Some input files use or override a deprecated API.

    Note: Recompile with -Xlint:deprecation for details.

    22 errors

    make: *** [out/target/common/obj/APPS/Ethernet_intermediates/classes-full-debug.jar] Error 41

    make: *** Waiting for unfinished jobs....

    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.

    Warning: AndroidManifest.xml already defines targetSdkVersion (in http://schemas.android.com/apk/res/android); using existing value in manifest.

     

    What may be the cause, why is the problem with EthernetDataTracker?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 9 years ago

    could someone please help!! im not even trying to compile my own android.. my riotboad died on me and i have all the files i need boot, recovery, system, and the uboot image, now could someone PLEASE tell me how i flash them on to the riotboard? all i can find is directions for flashing ubuntu using linux but not android using linux... im trying to flash android using linux mint. again please help...thanks!!

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube