分享好友 最新动态首页 最新动态分类 切换频道
HOWTO Setup Android Development
2024-12-27 03:18

This page should provide "how-to" document about using Fedora Linux for developing applications for Android platform.

HOWTO Setup Android Development

This document will cover requirements, steps how to go from source code till final application and how to use Android Emulator for testing of application.

F-12 and higher

  • Eclipse IDE (3.5 and higher is needed because of ADT plugin dependency on Equinox P2) can be installed using :
dnf install eclipse-jdt

Or with YUM:

yum install eclipse-jdt
  • Android SDK

Download SDK from page



    • Start Eclipse, then select Help > Install new software...
    • Click on the Available Software site hyperlink.
    • In Available software sites dialog, click Add....
    • In the Add Site dialog that appears, enter a name for the remote site (for example "Eclipse Update") in the "Name" field. In the Location field, enter one of these URLs, depending on your version of Eclipse. For Eclipse version 3.5 use:
http://download.eclipse.org/releases/galileo/

or for Eclipse version 3.6 use:

http://download.eclipse.org/releases/helios/

For Eclipse version 3.7 (Fedora 16 and current Rawhide (as of Oct. 10, 2011)), use:

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

For Eclipse version 4.2 (Fedora 17 and current Rawhide (as of Jun. 6, 2012)), use:

http://download.eclipse.org/releases/juno/

For Eclipse version 4.3 (Fedora 19 and current Rawhide (as of Jun. 5, 2013)), use:

http://download.eclipse.org/releases/kepler/

For Eclipse version 4.4 (Fedora 21 and current Rawhide (as of March 5, 2015)), use:

http://download.eclipse.org/releases/luna/

If you're unsure which version of Eclipse you are using, check it at Help > About Eclipse.

This will add dependency which are required for ADT plugin.

    • Again click on Add button and enter a name for the another remote site (for example, "Android Plugin") in the "Name" field. In the "Location" field, enter this URL:
https://dl-ssl.google.com/android/eclipse/ 

Note: If you have trouble acquiring the plugin, you can try using "http" in the URL, instead of "https" (https is preferred for security reasons).Click OK.

    • Click on each of the added sites and click Reload
    • Back in the Available Software view, next to "Work with:", you should now see "Android Plugin" in the drop down list, select it. In the box below, you will see "Developer Tools" added to the list. Select the checkbox next to Developer Tools, this 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.
  • Download the SDK from
  • Unpack it in your home directory, then rename it to ~/AndroidSDK
  • Add into path environment variable ~/AndroidSDK in .bash_profile file in your home directory.
    For example:
PATH=$PATH:$HOME/AndroidSDK:$HOME/AndroidSDK/tools
export PATH

# For SDK version r_08 and higher, also add this for adb:
PATH=$PATH:$HOME/AndroidSDK/platform-tools
export PATH
  • Logout and login back to apply path change

Install in Fedora 22 and later versions using :

# dnf install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686

Or with YUM in Fedora 21 and earlier versions:

# yum install glibc.i686 glibc-devel.i686 libstdc++.i686 zlib-devel.i686 ncurses-devel.i686 libX11-devel.i686 libXrender.i686 libXrandr.i686

  1. cd into the ~/AndroidSDK directory and run tools/android to configure and create your first Android Virtual Device.
  2. Go to "Available Packages", select components for just those versions of Android you want to work with. For example:
    • SDK Platform Android 2.1
    • Documentation for Android SDK
  3. (SDK version r_08) For the adb tool, make sure you also select:
    • Platform Tools
  4. Click on "Install selected", then click on "accept all" and confirm with clicking on "Install". This will start component installation, when it will be done, click on close. When this will be done, we could proceed with creation of AVD device itself.
  5. Go to "Virtual Devices", Click on "New", this will open screen where you need to specify SD card size (I will use 62MiB), name of device (I will use "android_dev1", target (Android 2.1, if you want to develop for different target, you need to go to step 2 and install SDK platform for different version).
  6. Now click on "Create AVD" which will create Android Virtual Device.

Now we have created Android Virtual Device and we should start it, however, due to issues in AndroidSDK with sound, we will need to run it from command line

https://fedoraproject.org/wiki/emulator -noaudio -avd android_dev1

And this will start emulator for us.


  1. Go to Window -> Preferences, click on Android and set SDK location to directory. (for example /home/user/AndroidSDK) and click on Apply.
  2. Click on apply to reload available targets
  3. choose target android SDK
  4. click on OK

After you've created an AVD, the next step is to start a new Android project in Eclipse.

  1. From Eclipse, select File > New > Project. If the ADT Plugin for Eclipse has been successfully installed, the resulting dialog should have a folder labeled "Android" which should contain "Android Project". (After you create one or more Android projects, an entry for "Android XML File" will also be available.)
  2. Select "Android Project" and click Next.
  3. On next screen type Project Name ("HelloFedora"), Application name (Hello, Fedora), package name (com.example.hellofedora) which represent your namespace and name of activity in "Create Activity" box (HelloFedora). Choose target (if you have multiple targets) and click on "Finish". This will create project for you.


  1. open HelloFedora.java and paste there example code from Hello Fedora Code section.
  2. click on windows -> preferences. In new window, open Android -> Launch and into "Options" text box insert "-noaudio"
  3. open separate console, cd ~/AndroidSDK/tools and execute https://fedoraproject.org/wiki/emulator -noaudio @android_dev1 to start emulator. Wait for start of emulator (it could take several minutes)
  4. in eclipse, click on "run" and it will deploy application into Android Virtual Device.

package com.example.hellofedora;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloFedora extends Activity {
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        TextView tv = new TextView(this);
        tv.setText("Hello, Android Developer
 Thank you, for using Fedora Linux");
        setContentView(tv);

    }
}

Since Android is open source software, we can compile the platform ourselves on our Fedora machines. You need to have at least 6GB of disk space free to build Android.

  • Make sure you have Java installed (Java <= 1.5 only for compiling Android <= 2.1). Preferably Sun Java rather than OpenJDK (OpenJDK should still work but issues are more likely to arise).
  • Ensure that these required packages are installed using or YUM:
dnf|yum install gcc gcc-c++ gperf flex bison glibc-devel.{x86_64,i686} zlib-devel.{x86_64,i686} ncurses-devel.i686 libsx-devel readline-devel.i686 perl-Switch
  • Obtain the Android "repo" tool.
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
  • Create a directory for the Android source trees (We'll use ~/android/source in this example)
mkdir -p ~/android/source
cd ~/android/source
  • Once in the directory, initialize the AOSP repository. (Only run one of these commands per directory)
# Initialize sources for the master branch of Android
repo init -u git://android.git.kernel.org/platform/manifest.git

# Initialize Cupcake (1.5)
repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake

# Initialize Donut (1.6)
repo init -u git://android.git.kernel.org/platform/manifest.git -b donut

# Initialize Eclair (2.0 - 2.1)
repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair

# Initialize Froyo (2.2)
repo init -u git://android.git.kernel.org/platform/manifest.git -b froyo

# Initialize Gingerbread (2.3)
repo init -u git://android.git.kernel.org/platform/manifest.git -b gingerbread
  • Now you need to start downloading the source trees from git, while in ~/android/source run:
repo sync
  • Before you can start building for your device, you will need to acquire some proprietary files directly from your device using the adb tool. There will be a script to do this in your device's configuration directory. While still in ~/android/source do:
# I.e for the Nexus One this would be "device/htc/passion"
cd device/<device_manufacturer>/<device_codename>

# The script name *should* be the same in all the devices directories...

  • To build the Android platform, the process is generally like this:
cd ~/android/source
source build/envsetup.sh
lunch      # <- (choose your device from the list)

# To build .img files of the platform (you will need to 'fastboot' these onto a device that supports fastboot):
make

# To build an OTA (Over The Air) package (zip files that carriers send out to devices for updates):
make otapackage

# To build a specific component, for example the Camera application:
make Camera
  • All output from the build process will be located in the directory contained by the shell variable $OUT (the $OUT directory will be different based on what product you lunched earlier). $OUT will generally be something like ~/android/source/out/target/product/<yourdevicename>
  • If your device is not in the 'lunch' list, it's because there is no official open source device config for your particular device. For example, at this point in time, the only device configs that come with the source trees, are the G1 (dream), MyTouch (sapphire), Nexus One (passion), and Nexus S (crespo). This is because they are directly related with Google and therefore just as open source as the rest of the platform.
  • If none of these are your Android device, luckily for us, there are open source developers that work on creating these for various devices. What you want to do is obtain the configuration repo, and put it in ~/android/source/device. The easiest way to do this is to use 'git' (provided by the "Development Tools" dnf|yum group. Git can be installed with DNF by command ). You can search to see if anyone has started working on a config for your specific device.
  • Of course to install your finished build, your Android device must allow root access with a custom recovery image installed. It should also be noted that by compiling Android from the instructions above (building from the official Android repositories), the resulting build will not have native root access, nor will it have the official Google applications (Gmail, YouTube, Market, etc., these can be installed afterward). To build your own development build with superuser access enabled, some more configuration to the source would be needed and is out of the scope of this tutorial. You could also build from alternate Android source trees, such as CyanogenMod () (if your device is supported by their project).
最新文章
青岛定制网页设计_青岛网页设计定制公司
青岛定制网页设计的优势分析:青岛定制网页设计能够根据企业自身的特点进行专门的设计,提供独一无二的网站体验。这样的设计方式不仅能够满足企业的品牌形象需求,还能有效地提升用户体验。通过定制化的网页设计,企业可以更好地展示自己的
预见2024:2024年中国在线旅游行业市场规模、竞争格局及发展前景预测 未来市场规模将超1.9万亿元
行业主要上市公司:携程(TCOM)、(TOUR)、同程旅行(0780)等本文核心数据:中国在线旅游交易规模;中国在线旅游平台排名;中国在线旅游区域竞争格局行业概况1、定义在线旅游是随着互联网发展而诞生的一种新型旅游商业模式,是指旅游消费者通过
英飞凌科技股份公司宣布已收购位于斯德哥尔摩的初创企业Imagimob有限公司,这是一家领先的平台提供商,致力于为边缘设备上的机器学习(ML)解决方案开发提供助力。通过此次收购,英飞凌进一步加强了其提供
TDK株式会社针对USB-C端口和其他高速接口的ESD保护应用推出一款超紧凑型TVS二极管。对于USB-C等符合USB4(第1版)规范且传输速度高达40 Gbit/s的高速接口 (Tx / Rx),ESD保护应用特别需要具有超低寄生电容和低钳位电压的TVS二极管。新的B74
自考靠谱的机构有哪些特点?
自考靠谱的机构有哪些特点?社会飞速发展,面临升职就业等压力,提升自我优势是必不可少的,拥有一个高学历或好文凭是关键,可以让就业的范围更广升职的机会更多。学历是判断个人素质的重要条件之一,企业也重视高学历的员工。下面本小编为
神马关键词推广_做神马关键词优化软件(神马关键词排名快速优化首页价格)
这个要具体看关键词的啊,差别的词是不一样的, 近来佛山市神马互联网科技有限公司推出关键词按天扣费很火,没有恶性点击,关键词24小时在线, 盼望可以帮到你;环境如下第一种,比方你是推广的北京地区假如你在上海,但是你账户启用了搜刮
阿里巴巴:今年营收 5000 亿,明年GMV要再增一万亿
疫情带来冲击和机遇,阿里稳健前行寻找向上新空间。5 月 22 日,阿里巴巴发布截至 3 月 31 日的 2020 年第四季度财报及全年财报。财报显示,2020 财年,阿里巴巴集团收入为人民币 5097.11 亿元,同比增长 35
Python爬虫教程——7个爬虫小案例(附源码)_爬虫实例
本文介绍了7个Python爬虫小案例,包括爬取豆瓣电影Top250、猫眼电影Top100、全国高校名单、中国天气网、当当网图书、糗事百科段子和新浪微博信息,帮助读者理解并实践Python爬虫基础知识。包含编程资料、学习路线图、源代码、
运动会活动策划书
~  时间一溜烟儿的走了,工作已经告一段落了,前方等待着我们的是新工作目标和挑战,想必现在的你有必要写一写策划书了。是不是无从下笔、没有头绪?下面是我收集整理的运动会活动策划书,仅供参考,欢迎大家阅读。    一、活动前言:
比漫熊漫画,比漫熊漫画安卓最新版,比漫熊漫画下载
比漫熊漫画是一款非常好用的小说漫画软件,比漫熊漫画功能丰富,确实在多个方面为漫画爱好者们提供了优质的阅读体验,用户可以根据类型地区作者等多种方式进行筛选,比漫熊漫画允许用户根据自己的需求切换各种漫画资源源,轻松找到自己喜欢
跨境电商独立站建站平台解析,独立站如何运营?独立站优势
越来越多的人涌入跨境电商这行业,无论是大平台还是独立站,蜂拥而至的小白,新手,各种开车,各种上路,但是大家真的了解独立站这个行业麽?或者说,怎么找到未来自己的第一块根据地呢?那么咱就说说,你只要干独立站,就怎么都绕不开的这
相关文章
推荐文章
发表评论
0评