CubieBoard中文论坛

 找回密码
 立即注册
搜索
热搜: unable
查看: 31949|回复: 28

Android开发从零开始,搭建交叉编译环境

[复制链接]
发表于 2013-5-13 15:49:33 | 显示全部楼层 |阅读模式
本帖最后由 siriux 于 2013-5-22 12:21 编辑

1.     Requirements
1.1  Hardware
1.1.1 CPU: Intel 2.5G I5 x64;
1.1.2 Memory: 16G DDR3;
1.1.3 Disk: 30GB;
1.1.4 Internet connected;
1.2 Software
1.2.1OS: Ubuntu 12.04(64 bit);
1.2.2Java JDK 6;
1.2.3Eclipse;
1.2.4ADT;
1.2.5CDT;
1.2.6Android SDK;
1.2.7Android NDK;
1.2.8Linux Source;
1.2.9Android Source.
2. Initializinga Build Environment
   Attention: Demonstration is in Ubuntu 12.04(32bit).
2.1 Installingthe JDK
The Sun JDK is no longer in Ubuntu's mainpackage repository. In order to download it, you need to add the appropriaterepository and indicate to the system which JDK should be used.
Inputthe following command in the Terminal:
$ sudo gedit /etc/apt/sources.list
Add:
Inputin terminal:
$ sudo add-apt-repository "debhttp://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
2.2 Installingthe Android SDK
Downloadthe SDK from Web Browser:
Choosethe adt-bundle-linux-x86-20130219.zip.

Inputin the terminal:
$ sudo mkdir ~/sdk
Copythe adt-bundle-linux-x86-20130219.zipto the /root/sdk and extract the zip.
Enterthe folder /root/sdk/adt-bundle-linux-x86-20130219/sdk/tools.


Doubleclick the script file android.

It willshow the Android SDK Manager. Choosethe package with ticks.

Thenclick the Install XX packages buttonon the right. It will start download the required packages.
Afterthe installation, add the SDK tools to PATHEnvironment Variable.
Inputin the terminal:
       $ gedit/etc/profile
Inputin the “profile”
       $ exportANDROID_SDK_PATH=/root/sdk/adt-bundle-linux-x86-20130219/sdk
       $ export PATH=.:$ANDROID_SDK_PATH/platform-tools:$PATH
Saveand close the profile.
Inputin the terminal:
       $ source/etc/profile
2.2 Installingthe Eclipse
Withthe download of adt-bundle-linux-x86-20130219.zip,we can find the Eclipse in the /root/sdk/adt-bundle-linux-x86-20130219/eclipse.

Doubleclick the eclipse can run it.
2.2.1Installing the ADT online
AndroidDevelopment Tools (ADT) is a plugin for the Eclipse IDEthat is designed to give you a powerful, integrated environment in which tobuild Android applications.        
ADTextends the capabilities of Eclipse to let you quickly set up new Androidprojects, create an application UI, add packages based on the Android Framework API, debug yourapplications using the Android SDK tools, and even export signed (or unsigned).apk files in order to distribute your application.
Run theeclipse and click the help>Install NewSoftware.
Then clickthe Add button.

Input the Name ADT.
Click OK. Then it will show the choice for installation.

Click Select All and Next.
2.2.2Installing the NDK
The NDKis a toolset that allows you to implement parts of your app using native-codelanguages such as C and C++. For certain types of apps, this can be helpful soyou can reuse existing code libraries written in these languages, but most appsdo not need the Android NDK.
Downloadthe NDK from Web Browser:
Choosethe android-ndk-r8e-linux-x86.tar.bz2.

Inputin the terminal:
$ sudo mkdir ~/ndk
Copythe android-ndk-r8e-linux-x86.tar.bz2to the /root/sdk and extract the zip.
Inputin the terminal:
$tar –xvf android-ndk-r8e-linux-x86.tar.bz2
Finally,add the NDK folder to PATH EnvironmentVariable.
2.2.3 Installing the CDT
       TheCDT Project provides a fully functional C and C++ Integrated DevelopmentEnvironment based on the Eclipse platform. Features include: support forproject creation and managed build for various toolchains, standard make build,source navigation, various source knowledge tools, such as type hierarchy, callgraph, include browser, macro definition browser, code editor with syntaxhighlighting, folding and hyperlink navigation, source code refactoring andcode generation, visual debugging tools, including memory, registers, anddisassembly viewers.
       Theinstallation of CDT is the same as ADT.
But theLocation of CDT is:
2.3Installing the Cross Compiling Environment
       TheCPU X86 is using the CISC, while the ARM processor is RISO. Therefore, thecross compiling environment should be installed.
TheCodeSourcery is an good choice for the cross compiling. It can be download fromthe following website.
Choosethe ARM Processor GNU/Linux release.

It willneed your personal information. Finally, system will send you an Email with thedownload URL.

Click the Download Sourcery CodeBench Lite 2012.09-64.


Choose the IA32 GNU/Linux Installer.

Afterdownload, enter the folder in terminal and use the following command:
       $ ln –s/lib/i386-linux-gnu/libc.so.6 /lib
$ dpkg-reconfigure dash
ChooseNO.

$ sh arm-2012.09-64-arm-none-linux-gnueabi.bin

Add theCodeSourvery to PATH.
Inputin the terminal:
       $ gedit/etc/profile
Inputin the profile.
           $export PATH=.:$/root/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_GNU_LIinux/bin:$PATH
Saveand close the profile.
Inputin the terminal:
       $ source/etc/profile
3. Test thefirst cross compiling environment
Programa simple first.c file.
#include<stdio.h>
int main()
{
              printf(“Hello world\n”);
              return 0;
}
Inputin the terminal:
       $ arm-none-linux-gnueabi-gcc–static –o first first.c
$ adb push first /data/local
$ adb shell
$ cd /data/local
$ ./first



Android Development Environment.pdf

770.97 KB, 下载次数: 639, 下载积分: 金钱 -1

评分

参与人数 3威望 +20 金钱 +20 贡献 +20 收起 理由
keonjeo + 5 + 5 + 5 赞一个!
linvorid + 5 + 5 + 5 神马都是浮云
matson + 10 + 10 + 10 赞一个!

查看全部评分

回复

使用道具 举报

发表于 2013-5-15 16:43:00 | 显示全部楼层
cc you,
1.1.1 CPU: Intel 2.5G I5 x64;
1.1.2 Memory: 16G DDR3;

这个配置太碉堡吧

i3 2120 + 8g ddr3 + 64 12.04表示毫无压力
回复 支持 反对

使用道具 举报

发表于 2013-5-15 18:22:47 | 显示全部楼层
linvorid 发表于 2013-5-15 16:43
cc you,
1.1.1 CPU: Intel 2.5G I5 x64;
1.1.2 Memory: 16G DDR3;

你这估计得编译2个小时吧。神舟笔记本,4核i7 8G内存,完全新编译android ics,45分钟搞定。
回复 支持 反对

使用道具 举报

发表于 2013-5-15 19:50:19 | 显示全部楼层
hipboi 发表于 2013-5-15 18:22
你这估计得编译2个小时吧。神舟笔记本,4核i7 8G内存,完全新编译android ics,45分钟搞定。 ...

其实三个多小时,呵呵。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-5-16 00:02:24 | 显示全部楼层
linvorid 发表于 2013-5-15 16:43
cc you,
1.1.1 CPU: Intel 2.5G I5 x64;
1.1.2 Memory: 16G DDR3;

这个是官方推荐的。呵呵
回复 支持 反对

使用道具 举报

发表于 2013-5-16 08:51:24 | 显示全部楼层
谢谢分享
回复 支持 反对

使用道具 举报

发表于 2013-5-16 14:04:50 | 显示全部楼层
linvorid 发表于 2013-5-15 16:43
cc you,
1.1.1 CPU: Intel 2.5G I5 x64;
1.1.2 Memory: 16G DDR3;

我一般两个小时!
回复 支持 反对

使用道具 举报

发表于 2013-5-16 14:06:33 | 显示全部楼层
我现在都是在ubuntu 里面编译源码,生成固件,在xp下烧录固件,eclipse编程开发
双系统
回复 支持 反对

使用道具 举报

发表于 2013-5-16 17:05:40 | 显示全部楼层
sdk开发eclipse还有更好的选择吗?,看新闻google好像要出个啥studio
另,win7 32位似乎加载不起驱动livesuit,所以我也是在winxp上烧的。
回复 支持 反对

使用道具 举报

发表于 2013-5-17 10:51:16 | 显示全部楼层
f839903061 发表于 2013-5-16 14:06
我现在都是在ubuntu 里面编译源码,生成固件,在xp下烧录固件,eclipse编程开发
双系统 ...

你不知道livesuite有linux版么?直接ubuntu开发搞定所有。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|粤ICP备13051116号|cubie.cc---深刻的嵌入式技术讨论社区

GMT+8, 2024-11-26 09:18 , Processed in 0.029272 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2012 Comsenz Inc. | Style by Coxxs

返回顶部