文档章节

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

cubieboard
 cubieboard
发布于 2014/08/21 11:49
字数 771
阅读 196
收藏 0

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:

$ deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse

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:

http://developer.android.com/sdk/index.html

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.

Input the Locationhttps://dl-ssl.google.com/android/eclipse.

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:

http://developer.android.com/sdk/ndk/index.html

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:

http://download.eclipse.org/tools/cdt/releases/indigo

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.

http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/

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


本文转载自:http://forum.cubietech.com/forum.php?mod=viewthread&tid=430

cubieboard
粉丝 11
博文 64
码字总数 2651
作品 1
珠海
私信 提问
Android原生(Native)C开发之一 环境搭建篇

转载: 转载: Android原生(Native)C开发之一 环境搭建篇 Android是基于Linux的操作系统,处理器是ARM的,所以要在Linux或Windows等x86系统上编译Android能运行的程序,你需要一个交叉编译器。...

迷糊
2009/10/10
9.5K
3
跟着石头哥哥学cocos2d-x(一)---2dx环境搭建 (win7)

之前一直忙于游戏后台的开发,也没有时间整理,本人热衷游戏开发,现工作之余准备整理2dx引擎方面的东西,方便大家学习以及自己备忘吧,废话少说直接上菜: 环境搭建分以下步走: 1.开发环境...

石头哥哥
2013/11/03
7.2K
36
Android NDK 原理

本文介绍Android NDK 原理, 熟悉此教程, 需要有JNI的基础, 以及Android 应用程序的入门知识(环境搭建, 工程运行等), 可以查看本站的其它文章. 本文关注Android NDK的原理知识. 关于JNI的基本...

晨曦之光
2012/03/07
580
0
Easy系列的安卓Android ndk编译EasyRTSPClient、EasyRTMPClient、EasyPusher、EasyRTMP、EasyIPCamera底层ndk so的流程记录

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 https://blog.csdn.net/xiejiashu/article/details/95674941 这是一篇开发的日常记录,现在发...

xiejiashu
07/12
0
0
Android NDK 原理

本文介绍Android NDK 原理, 熟悉此教程, 需要有JNI的基础, 以及Android 应用程序的入门知识(环境搭建, 工程运行等), 可以查看本站的其它文章. 本文关注Android NDK的原理知识. 关于JNI的基本...

晨曦之光
2012/03/09
385
0

没有更多内容

加载失败,请刷新页面

加载更多

Vue nodejs商城项目-搭建express框架环境

本文转载于:专业的前端网站➯Vue nodejs商城项目-搭建express框架环境 1.express-project 搭建express框架环境 安装express generator生成器 通过生成器自动创建项目 配置分析 安装 cnpm i -...

前端老手
5分钟前
0
0
maven项目A引入maven项目B的jar包

首先打开 项目B 的 pom 文件,加入如下配置 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin<......

嘴角轻扬30
9分钟前
0
0
一个突然出现的诡异bug

突然从昨天的某个时刻开始,程序报错了,作为接管该项目的我只能从找日志开始:这是打印的日志 日志已经很清楚了,说的的验签或者解密失败了! 好吧,我把代码拉下来瞅瞅,这是打印日志的地方...

布袋和尚_爱吃鱼
14分钟前
1
0
按位与(&)运算符应用实践

按位与运算是将数字转换成二进制格式进行位运算。 1、&的运算方法(奇偶性判断) 整数与“1”进行按位与运算,运算结果为“0”表示为偶数,运算结果为“1”表示为奇数。 <?php//将数组中...

尤金
24分钟前
1
0
java常量池

https://blog.csdn.net/qq_41376740/article/details/80338158

南桥北木
28分钟前
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部