fedora12 下Android 开发环境搭建
由于版本变化,原来的安装步骤会有些问题,所以重新整理如下:
最好每次安装时先看看google的说明,http://developer.android.com/sdk/installing.html, 有些变化可以在这里看到,避免不必要的折腾。
1. 需要:
a. android sdk(required)
b. jdk(required)
c. eclipse(optional)
d. ADT(optional)
2. 先检查是否已经安装 jkd:
java -version;
如果已经安装,看看版本是否符合要求。
我这里安装的是opentjdk,通过 yum install java-1.6.0-openjdk-devel安装,你可以到oracle官网去安装jdk1.6
3. 下载sdk( 到http://developer.android.com/sdk/index.html下载。注意这里下载的其实不是SDK,而是SDK Manager或者全称叫Android SDK and AVD Manager);;
4. 下载eclipse(到http://www.eclipse.org/downloads/下载。我下的是Eclipse 3.6(Helios) for Java Developer );
5. 下载ADT,然后通过archive方式安装到eclipse
(using existing SDK)
6. 配置JRE
执行菜单Window>Preferences;打开Java>Installed JREs;点击Search…指定到2.1中安装的Java路径。
7. 配置ADT
执行菜单Window > Preferences;打开Android,在SDK Location那里点击Browse..选择SDK的根目录android-sdk-linux。
验证——走向Android世界HelloAndroid
1 创建一个AVD
Eclipse中,通过菜单或者直接执行android-sdk-linux\ SDK Manager.exe。
在Virtual devices中,点击New…,创建一个AVD
2 创建HelloAndroid
创建项目,执行菜单File > New > Project…
选Android > Android Project,点击Next。
在弹出的窗体中设置各个属性如下:
[plain] view plaincopyprint?
01.Project name: HelloAndroid;
02.Build Target: 选择Android 2.2;
03.Application name: Hello, Android;
04.Package name: com.android.test
05.Create Activity: HelloAndroid
Project name: HelloAndroid;
Build Target: 选择Android 2.2;
Application name: Hello, Android;
Package name: com.android.test
Create Activity: HelloAndroid
点击Finish。
3 运行
Package View中,选中HelloAndroid这个项目,然后右击选择Run as -> Android Application。
issues:
1. Cannot complete the install because one or more required items could not be found.
Software being installed: Android Traceview 16.0.1.v201112150204-238534 (com.android.ide.eclipse.traceview.feature.group 16.0.1.v201112150204-238534)
Missing requirement: Android Traceview 16.0.1.v201112150204-238534 (com.android.ide.eclipse.traceview.feature.group 16.0.1.v201112150204-238534) requires 'org.eclipse.core.runtime 3.6.0' but it could not be found
solution:
you just need Ecplise Helios
ADT 16.0.1 (December 2011)
Dependencies: Eclipse Helios (Version 3.6) or higher is required for ADT 16.0.1.
ADT 16.0.1 is designed for use with SDK Tools r16. If you haven't already installed SDK Tools r16 into your SDK, use the Android SDK Manager to do so.
taken from http://developer.android.com/sdk/eclipse-adt.html
http://developer.android.com/sdk/index.html
The link above consist of some easy steps:
1. Download an tar.gz of the SDK.
2. Unzip it to a directory of your choice (I choose the same directory as my eclipse installation: /home/user/workspace/android-sdk)
3. Open up eclipse and go and 'attach' your eclipse to the google adt plugins.
4. Install the plugins that you "attached" in step 3.
5. Your done.
I wanted to keep this short and sweet which is why the link above points to the google page - the instructions worked fine for me.
The last thing that you will have to do is install the 686 or 32 bit compatible libraries to use the google provided ANDROID ADT and emulator. They haven't released the x86_64 which is why this HAS to be done.
1. Copy and paste what you see below to a file called i686.txt.
| arts.i686 audiofile.i686 bzip2-libs.i686 cairo.i686 compat-expat1-1.95.8-4.i686 compat-libstdc++-33-3.2.3-63.i686 compiz.i686 cyrus-sasl-lib.i686 dbus-libs.i686 directfb.i686 esound-libs.i686 fltk.i686 freeglut.i686 gphoto2.i686 gtk2.i686 hal-libs.i686 imlib.i686 jack-audio-connection-kit.1.i686 java.i686 lcms-libs.i686 lesstif.i686 libacl.i686 libaio-0.3.106-4.2.i686 libao.i686 libattr.i686 libcap.i686 libdrm.i686 libexif.i686 libgcrypt-1.4.0-3.i686 libgnomecanvas.i686 libICE.i686 libieee1284.i686 libsigc++20.i686 libSM.i686 libtool-ltdl.i686 libusb.i686 libwmf.i686 libwmf-lite.i686 libX11.i686 libXau.i686 libXaw.i686 libXcomposite.i686 libXdamage.i686 libXdmcp.i686 libXext.i686 libXfixes.i686 libxkbfile.i686 libxml2.i686 libXmu.i686 libXp.i686 libXpm.i686 libXScrnSaver.i686 libxslt.i686 libXt.i686 libXTrap.i686 libXtst.i686 libXv.i686 libXxf86vm.i686 lzo.i686 mesa-libGL.i686 mesa-libGLU.i686 nas-libs.i686 nss_ldap.i686 opencdk.i686 openldap.i686 pam.i686 popt.i686 pulseaudio-libs.i686 sane-backends-libs-gphoto2.i686 sane-backends-libs.i686 SDL.i686 svgalib.i686 unixODBC.i686 zlib.i686 |
2. Issue the following command:
| for i in $(< i686.txt); do sudo yum -y install $i ; done |
Done.
Remember - you will have to 'create' the virtual android device that you want to use, before compiling and running any programs. This only has to be done once for every version of the phone you want to run(ie android 1.5, android 1.6, android 2.1, android 2.2) It is kind of like creating a virtual machine. Only the Virtual Machine is a virtual android phone.
1. 下载 Android SDK
前往从以下网站获取 Android Linux 平台的 SDK 套件,这个都一样,当然这个网址已经被墙了,所有各尽所能爬出去吧
http://developer.android.com/sdk/
2. 解压缩并配置相关环境变量
将获得的 zip 解压到所喜好的位置即可,无须安装。
接下来需要将 SDK 目录中的 tools 添加到 PATH 路径中,方便调用。编辑 $HOME/.bash_profile 文件,在 PATH 一行末尾添加 SDK 中 tools 文件路径即可,用冒号分割。
如:
export PATH=${PATH}:<your_sdk_dir> /tools
使环境变量即时生效的命令
source .bash_profile
推荐为其 Android SDK 目录创建一个不包括版本号的符号链接,这样日后 SDK 升级时就无须调整 PATH 路径了。
3. 安装 Eclipse 集成开发环境
Android 推荐的 IDE 为 Eclipse,使用下面的命令安装它:
.su -c 'yum install eclipse-jdt java-1.6.0-openjdk-devel'
即可获得 Fedora Eclipse 3.5.1 版本。
4.配置 Android Development Tools
google官方给出了配置方法在 http://developer.android.com/sdk/eclipse-adt.html
我配置的时候出现错误:
Cannot complete the install because one or more required items could not be found.
Software being installed: Android Development Tools 0.9.5.v200911191123-20404 (com.android.ide.eclipse.adt.feature.group 0.9.5.v200911191123-20404)
Missing requirement: Android Development Tools 0.9.5.v200911191123-20404 (com.android.ide.eclipse.adt.feature.group 0.9.5.v200911191123-20404) requires 'org.eclipse.wst.xml.ui 0.0.0' but it could not be found
解决方法如下:
For some reason ubuntu doesn't include the standard update repository for Eclipse by default. To fix this:
- Go to "Help/Install New Software..."
- Add http://download.eclipse.org/releases/galileo/ to the update sites list (strange it's not installed by default on ubuntu)
- From there, install WST (use the filter box to find the package)
- Restart eclipse
然后按照官方的方法配置
- Start Eclipse, then select Help > Install New Software .
- In the Available Software dialog, click Add... .
- In the Add Site dialog that appears, enter a name for the remote site (for example, "Android Plugin") in the "Name" field.
In the "Location" field, enter this URL:
https
:
//dl-ssl.google.com/android/eclipse/
-
Click OK .
- Back in the Available Software view, you should now see "Developer Tools" added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next .
- In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish .
- Restart Eclipse.
现在只是配置好开发环境,android各个版本但sdk还没有下载
android list targets
发现没有可用的设备
输入 android 打开图形配置界面
- Select Available Components in the left panel. This will reveal all components currently available for download.
- Select the components you'd like to install and click Install Selected .
- Verify and accept the components you want and click Install Accepted . The components will now be installed into your existing Android SDK directories.
If your computer can't get a listof targets via the default "https" URL, then go to the Settings tab inthe "Android SDK and AVD Manager" and click on "Force https://...sources to be fetched using http://..."
现在发现有设备了,按照官方的方法
http://androidappdocs.appspot.com/guide/tutorials/hello-world.html
android create avd
--
target
2
--
name my_avd
其中target后面的数字就是“ android list targets ”查到的设备id,最后的名字自己取,我命名为avd_版本号
直接回车,采用默认设置
然后打开Eclipse,在window--Preference--Android中把SDK的目录加入进来

浙公网安备 33010602011771号