侯体宗的博客
  • 首页
  • Hyperf版
  • beego仿版
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

Linux下Android开发环境搭建详细步骤

linux  /  管理员 发布于 7年前   186

1、系统环境

[android@localhost ~]$ uname -a

Linux localhost.localdomain 2.6.32-71.el6.i686 #1SMP Wed Sep 1 01:26:34 EDT 2010 i686 i686 i386 GNU/Linux

[android@localhost ~]$ lsb_release -a

LSB Version:   :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch

Distributor ID: RedHatEnterpriseServer

Description:   Red Hat Enterprise Linux Server release 6.0 (Santiago)

Release:       6.0

Codename:      Santiago

[android@localhost ~]$

2、准备软件

java

eclipse

android-sdk

ADT

这些软件都可以在官网上下载。

3、搭建过程

(1)           安装java

[android@localhost ~]$ rpm -qa | grep java

eclipse-mylyn-java-3.3.2-4.5.el6.i686

java-1.6.0-openjdk-devel-1.6.0.0-1.21.b17.el6.i686

java-1.6.0-openjdk-1.6.0.0-1.21.b17.el6.i686

tzdata-java-2010l-1.el6.noarch

gcc-java-4.4.4-13.el6.i686

java-1.5.0-gcj-1.5.0.0-29.1.el6.i686

subversion-javahl-1.6.11-2.el6.i686

ooobasis3.3-javafilter-3.3.0-9567.i586

libvirt-java-0.4.5-2.el6.noarch

lpg-java-compat-1.1.0-4.1.el6.noarch

libvirt-java-devel-0.4.5-2.el6.noarch

mysql-connector-java-5.1.12-2.el6.i686

ant-javamail-1.7.1-13.el6.i686

java-1.6.0-openjdk-javadoc-1.6.0.0-1.21.b17.el6.i686

java_cup-0.10k-5.el6.i686

[android@localhost ~]$

通过命令查看当前已经安装了java的相关jdk,可以进行下一步。

(2)           安装eclipse

从官网上下载的eclipse不需要按装,直接解压即可使用。如:

[android@localhost Base Env]$ ls

ADT-18.0.0.zip

android-sdk_r18-linux.tgz

Android开发环境搭建(Linux篇).doc

eclipse

eclipse-cpp-indigo-SR2-incubation-linux-gtk.tar.gz

Linux环境搭建.doc

Linux 下Android 开发环境搭建 .doc

[android@localhost Base Env]$ rm -R eclipse

[android@localhost Base Env]$ ls

ADT-18.0.0.zip

android-sdk_r18-linux.tgz

Android开发环境搭建(Linux篇).doc

eclipse-cpp-indigo-SR2-incubation-linux-gtk.tar.gz

Linux环境搭建.doc

Linux 下Android 开发环境搭建 .doc

[android@localhost Base Env]$ tar -zxfeclipse-cpp-indigo-SR2-incubation-linux-gtk.tar.gz

[android@localhost Base Env]$ ls

ADT-18.0.0.zip

android-sdk_r18-linux.tgz

Android开发环境搭建(Linux篇).doc

eclipse

eclipse-cpp-indigo-SR2-incubation-linux-gtk.tar.gz

Linux环境搭建.doc

Linux 下Android 开发环境搭建 .doc

[android@localhost Base Env]$ cd eclipse

[android@localhost eclipse]$ ls

about_files   configuration  eclipse.ini   icon.xpm         p2

about.html    dropins        epl-v10.html  libcairo-swt.so  plugins

artifacts.xml eclipse        features      notice.html      readme

[android@localhost eclipse]$ ll

总用量 540

drwxrwxr-x. 2 android android   4096  2月 17 03:06 about_files

-rw-rw-r--. 1 android android  18909  2月 8 21:55 about.html

-rw-rw-r--. 1 android android  88246  2月 17 03:06 artifacts.xml

drwxrwxr-x. 5 android android   4096  2月 17 03:06 configuration

drwxrwxr-x. 2 android android   4096  2月 17 03:06 dropins

-rwxr-xr-x. 1 android android  62814  2月 8 22:16 eclipse

-rw-rw-r--. 1 android android    407  2月 17 03:06 eclipse.ini

-rw-rw-r--. 1 android android  16536  2月 8 21:36 epl-v10.html

drwxrwxr-x. 46 android android   4096 2月 17 03:06 features

-rw-rw-r--. 1 android android   9022  2月 8 21:54 icon.xpm

-rwxr-xr-x. 1 android android 266168  2月  8 21:54 libcairo-swt.so

-rw-rw-r--. 1 android android   8951  2月 8 21:36 notice.html

drwxrwxr-x. 5 android android   4096  2月 17 03:05 p2

drwxrwxr-x. 10 android android  36864 2月 17 03:06 plugins

drwxrwxr-x. 2 android android   4096  2月 17 03:06 readme

[android@localhost eclipse]$ ./eclipse

启动eclipse之后,eclipse会自动创建并寻找workspace文件夹,可以直接点击ok按钮即可。eclipse的启动过程如下图所示:

eclipse也可以在gnome桌面下直接双击eclipse可执行文件启动。

(3)           安装android-sdk
 

[android@localhost Base Env]$ tar -zxfandroid-sdk_r18-linux.tgz

[android@localhost Base Env]$ ls                                

ADT-18.0.0.zip                                                  

android-sdk-linux                                               

android-sdk_r18-linux.tgz                                       

Android开发环境搭建(Linux篇).doc                                

eclipse                                                         

eclipse-cpp-indigo-SR2-incubation-linux-gtk.tar.gz              

Linux环境搭建.doc                                               

Linux 下Android 开发环境搭建 .doc                               

[android@localhost Base Env]$ cdandroid-sdk-linux/             

[android@localhost android-sdk-linux]$ ls                       

add-ons platforms  SDK Readme.txt  tools                       

[android@localhost android-sdk-linux]$ cd tools/                

[android@localhost tools]$ ll

总用量 6772

-rw-rw----. 1 android android     323 3月 30 23:20 adb_has_moved.txt

-rwxrwx---. 1 android android    3491 3月 30 23:19 android

drwxrwx---. 2 android android    4096 3月 30 23:19 ant

-rwxrwx---. 1 android android    1977 3月 30 23:19 apkbuilder

drwxrwx---. 3 android android    4096 3月 30 23:19 apps

-rwxrwx---. 1 android android    3116 3月 30 23:19 ddms

-rwxrwx---. 1 android android   46724 3月 30 23:19 dmtracedump

-rwxrwx---. 1 android android    1940 3月 30 23:19 draw9patch

-rwxrwx---. 1 android android   24828 3月 30 23:19 emulator

-rwxrwx---. 1 android android 2814128  3月 30 23:19 emulator-arm

-rwxrwx---. 1 android android 2765428  3月 30 23:19 emulator-x86

-rwxrwx---. 1 android android  136860 3月 30 23:19 etc1tool

-rwxrwx---. 1 android android    3282 3月 30 23:19 hierarchyviewer

-rwxrwx---. 1 android android    9680 3月 30 23:19 hprof-conv

drwxrwx---. 6 android android    4096 3月 30 23:19 lib

-rwxrwx---. 1 android android    2015 3月 30 23:19 lint

-rwxrwx---. 1 android android    9676 3月 30 23:19 mksdcard

-rwxrwx---. 1 android android    3169 3月 30 23:19 monkeyrunner

-rw-rw----. 1 android android  379587 3月 30 23:20 NOTICE.txt

drwxrwx---. 7 android android    4096 3月 30 23:19 proguard

-rw-rw----. 1 android android      66 3月 30 23:19 source.properties

-rwxrwx---. 1 android android  613856 3月 30 23:19 sqlite3

drwxrwx---. 2 android android    4096 3月 30 23:19 support

-rwxrwx---. 1 android android    3044 3月 30 23:19 traceview

-rwxrwx---. 1 android android   46784 3月 30 23:19 zipalign

[android@localhost tools]$ ./android update sdk

此处即打开了android模拟器的升级更新界面,如下图所示:

接下来的操作主要是对该模拟器中的相关包进行下载升级,需要的时间可能会很长(本人在进行升级时基本上会在晚上保持开机,因为Android系统之间得不兼容性。当然,您如果只是针对某一个Android系统版本,那会快很多。不过在以后也可以追加下载安装的。):

您可以选择Aceept all:


      点击Install按钮之后,您会跳转到下面的界面中,其中,在该对话框的最下面,您会看到当前包的下载速度与进度:


      AndroidSDK Manager有时候也会弹出下面的log对话框,这里面可以看到更加详细的信息(您可以关闭该对话框。如果您下一次确实需要看,您可以点击后色按钮后面的那个按钮,管理器会打开日志对话框):

在android-sdk安装成功之后,在该目录下,Android SDK Manager会创建platform-tools文件夹,该文件夹中包含了您已定会用到的adb等android命令。

下载过程中,SDK Menager会弹出如下图的站点认证信息,可忽略该认证:

在下载安装完成后,安卓SDK 管理器会弹出下面的对话框:

此时,您可以勾选标注为Not installed的相关包,点击Install*package可以安装您选择的没有安装的相关包,但此时安装的包大都需要您给出站点认证信息。相关信息截图如下:

  至此,Android SDK Manager安装完毕。

 

(4)           安装ADT插件

首先,您要启动eclipse;

在IDE中点击Help->Install New Software...打开eclipse的Install对话框,如下图所示:


 

  点击Add...按钮,打开Add Repository对话框:

    在这一步周中,您可一在Location输入框中填入您下载ADT的URL。但此时,为了提高安装速度,可以先将ADT下载到本地,然后点击Archive...按钮:


 

这时,需要选择您刚才下载的ADT(记得,一定不要解压):

在这里,直接点击ok就可以了:


      勾选Name中的Developer Tools,直接点击Next,进行安装:

  这时,就需要接受协议条款了,接下来直接点击Finish按钮:


      在安装界面,您可以点击Details>>按钮查看当前的详细信息,此时在Eclipse的IDE界面的右下角也会给出进度提示:


      插件安装过程中,可能会弹出来下面的警告信息,看完消息之后,您会和我一样点击确定按钮的:

    安装完成后,Eclipse会让您选择是否重启Eclipse来应用您刚刚给IDE带来的新变化,这就因时而异了:

    重启进入Eclipse之后,一般情况下,会弹出Welcome to Android Development的对话框:

    如果没有弹出该对话框,可以在Window->Perferences中的Android进行必要的设置,

    该设置项位于SDK Location下。

     这里需要设置的是Target Location,您可一点击Browse...来浏览选择您之前安装的Android-sdk-linux的路径地址:


点击确定即可:

接下来,就是简单的Next:

接下来需要选择可安装的包,一般点击Accept All:

  这一过程安装完成之后,可以通过Eclipse中的Window->AVD Manager打开Android Virtual Device Manager。也可一通过tools下的android bash文件打开,不过可能稍微有一点困难,应该是不建议的打开方式。

设置创维M6的平板”驱动”

(请允许这么称呼,只是因为类似与Windows下的驱动效果,如此设置后,既可以打开创维M6的adb使用)

1、使用lsusb命令查看系统的USB设备:

[android@bogon ~]$ lsusb

Bus 002 Device 005: ID 0bb4:0c02 High Tech ComputerCorp. Dream / ADP1 / G1 Phone (Debug)                                                                       

Bus 002 Device 003: ID 093a:2510 Pixart Imaging,Inc. Optical Mouse            

Bus 002 Device 002: ID 8087:0020 Intel Corp.Integrated Rate Matching Hub      

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation2.0 root hub                  

Bus 001 Device 002: ID 8087:0020 Intel Corp.Integrated Rate Matching Hub      

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation2.0 root hub                 

[android@bogon ~]$

由此可以看出,进入Debug模式下的0bb4是创维M6的ID。

2、切换之android-sdk-linux的tools目录下,更新adb:                                   

[android@bogon tools]$ ./androidupdate adb

adb has been updated. You must restart adb with thefollowing commands

  adbkill-server                                               

  adbstart-server

[android@bogon tools]$

3、尝试查看Android设备:                                                                                          

[android@bogon platform-tools]$ ./adb devices                         

* daemon not running. starting it now on port 5037*                 

* daemon started successfully *                                      

List of devices attached                                             

????????????   no permissions                                        

[android@bogon platform-tools]$

可以看出,该命令执行失败,返回的结果,本人不知。

4、加入创维M6的ID到adb_usb.ini文件下(必须拥有root权限,并且该文件存在于隐藏的.android文件夹下):

[android@bogon ~]$ suroot              

密码:                                 

[root@bogon android]# ls-al            

总用量 200                             

drwx------. 34 android android 4096  4月 13 09:10 .

drwxr-xr-x. 5 root    root    4096 4月 13 08:57 ..

drwx------. 3 android android 4096  4月 13 09:01 .adobe

drwxrwxr-x. 3 android android 4096  4月 13 09:18 .android

drwxrwxr-x. 4 android android 4096  4月 13 09:13 Base Env

-rw-r--r--. 1 android android   18  6月 22 2010 .bash_logout

-rw-r--r--. 1 android android  176  6月 22 2010 .bash_profile

-rw-r--r--. 1 android android  124  6月 22 2010 .bashrc     

drwxr-xr-x. 3 android android 4096  4月 13 08:58 .cache      

drwxr-xr-x. 6 android android 4096  4月 13 09:13 .config    

drwx------. 3 android android 4096  4月 13 08:58 .dbus      

-rw-r--r--. 1 android android  500  1月 24 2007 .emacs      

-rw-------. 1 android android   16  4月 13 08:58 .esd_auth  

drwx------. 4 android android 4096  4月 13 08:59 .gconf     

drwx------. 2 android android 4096  4月 13 09:09 .gconfd    

drwxr-xr-x. 7 android android 4096  4月 13 09:07 .gnome2    

drwx------. 2 android android 4096  4月 13 08:58 .gnome2_private

drwxrwxr-x. 3 android android 4096  4月 13 08:58 .gnote        

drwx------. 2 android android 4096  4月 13 08:58 .gnupg        

drwxrwxr-x. 2 android android 4096  4月 13 08:58 .gstreamer-0.10

-rw-rw-r--. 1 android android  200  4月 13 08:58 .gtk-bookmarks

drwx------. 2 android android 4096  4月 13 08:58 .gvfs         

-rw-------. 1 android android  310  4月 13 08:58 .ICEauthority 

-rw-r--r--. 1 android android  794  4月 13 08:58 .imsettings.log

drwx------. 3 android android 4096  4月 13 09:09 .kde          

-rw-r--r--. 1 android android  121  6月 29 2010 .kshrc         

drwxr-xr-x. 3 android android 4096  4月 13 08:58 .local        

drwx------. 3 android android 4096  4月 13 09:01 .macromedia   

-rw-r--r--. 1 android android  124  6月 25 2010 .mkshrc         

drwxr-xr-x. 5 android android 4096  4月 13 08:58 .mozilla      

drwxr-xr-x. 2 android android 4096  4月 13 08:58 .nautilus     

drwx------. 2 android android 4096  4月 13 08:58 .pulse        

-rw-------. 1 android android  256  4月 13 08:58 .pulse-cookie 

-rw-------. 1 android android  218  4月 13 09:07 .recently-used.xbel

drwxrwxr-x. 3 android android 4096  4月 13 08:58 .redhat           

drwx------. 2 android android 4096  4月 13 08:58 .ssh              

drwx------. 3 android android 4096  4月 13 09:10 .thumbnails       

drwxrwxr-x. 3 android android 4096  4月 13 09:10 workspace         

-rw-------. 1 android android   50  4月 13 08:57 .xauthoxIGCv      

-rw-------. 1 android android 4401  4月 13 09:26 .xsession-errors  

-rw-r--r--. 1 android android  658 12月  9 2009 .zshrc             

drwxr-xr-x. 2 android android 4096  4月 13 08:58 公共的            

drwxr-xr-x. 2 android android 4096  4月 13 08:58 模板              

drwxr-xr-x. 2 android android 4096  4月 13 08:58 视频              

drwxr-xr-x. 2 android android 4096  4月 13 08:58 图片              

drwxr-xr-x. 2 android android 4096  4月 13 08:58 文档              

drwxr-xr-x. 2 android android 4096  4月 13 09:13 下载              

drwxr-xr-x. 2 android android 4096  4月 13 08:58 音乐               

drwxr-xr-x. 2 android android 4096  4月 13 08:58 桌面                                           

[root@bogon android]# cd.android/

[root@bogon .android]# ls        

adb_usb.ini avd                 

[root@bogon .android]# vimadb_usb.ini

[root@bogon .android]# lsusb          

Bus 002 Device 008: ID 0bb4:0c02 High Tech ComputerCorp. Dream / ADP1 / G1 Phone (Debug)                                                                      

Bus 002 Device 003: ID 093a:2510 Pixart Imaging,Inc. Optical Mouse             

Bus 002 Device 002: ID 8087:0020 Intel Corp.Integrated Rate Matching Hub      

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation2.0 root hub                 

Bus 001 Device 002: ID 8087:0020 Intel Corp.Integrated Rate Matching Hub      

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation2.0 root hub                 

[root@bogon .android]# gvimadb_usb.ini

                             

 

# ANDROID 3RD PARTY USBVENDOR ID LIST – DO NOT EDIT.

# USE 'android updateadb' TO GENERATE

# 1 USB VENDOR ID PERLINE.'

0x0bb4#该段的前面的内容为该文件原来保存的内容,只需在最后添加创维M6的ID即可。

5、以root权限创建文件/etc/udev/rules.d/im-android.rules文件,并在其中添加下面红色加粗的文字,其中的含义,您可以猜得懂。记得给该文件赋予可读可执行权限。

[root@bogon .android]# cd..                                                   

[root@bogon android]# cd..                                                    

[root@bogon home]# gvim/etc/udev/rules.d/imx-android.rules


SUBSYSTEM==”usb”,SYSFS{idVendor}==”0bb4”,MODE=”0666”


[root@bogon home]# gvim/etc/bash.bashrc                  

[root@bogon home]# exit                                   

exit                                                      

[android@bogon ~]$ cdBase\ Env/                                                         

[android@bogon Base Env]$ ls

ADT-18.0.0.zip             eclipse

android-sdk-linux         eclipse-cpp-indigo-SR2-incubation-linux-gtk.tar.gz

android-sdk_r18-linux.tgz                                                   

[android@bogon Base Env]$ cd android-sdk-linux/

[android@bogon android-sdk-linux]$ ls          

add-ons docs  platforms  platform-tools  SDK Readme.txt  temp tools                             

[android@bogon android-sdk-linux]$ cd platform-tools/               

[android@bogon platform-tools]$ ./adb devices                       

List of devices attached                                            

????????????   no permissions                                      

[android@bogon platform-tools]$ ./adb kill-server

[android@bogon platform-tools]$ ./adb start-server

* daemon not running. starting it now on port 5037*

* daemon started successfully *                    

[android@bogon platform-tools]$ ./adb devices      

List of devices attached                           

????????????   no permissions                     

[android@bogon platform-tools]$ cd /etc/udev/rules.d

[android@bogon rules.d]$ ll                         

总用量 76                                          

-rw-r--r--. 1 root root 6627  6月 24 2010 40-hplip.rules

-rw-r--r--. 1 root root  226  8月 18 2010 51-dlm.rules 

-rw-r--r--. 1 root root  495  6月 24 2010 56-hpmud_support.rules

-rw-r--r--. 1 root root 1652  8月 26 201060-fprint-autosuspend.rules

-rw-r--r--. 1 root root 1060  6月 29 2010 60-pcmcia.rules           

-rw-r--r--. 1 root root  452  8月 13 2010 60-raw.rules              

-rw-r--r--. 1 root root  292  7月 17 2010 70-cups-libusb.rules      

-rw-r--r--. 1 root root  788  2月 21 02:41 70-persistent-cd.rules   

-rw-r--r--. 1 root root  460  2月 21 01:49 70-persistent-net.rules  

-rw-r--r--. 1 root root 1914  1月 13 2010 85-pcscd_ccid.rules       

-rw-r--r--. 1 root root  320  5月 15 2009 90-alsa.rules             

-rw-r--r--. 1 root root   83  7月 28 2010 90-hal.rules &


  • 上一条:
    Linux操作系统下设置基本网络参数四种方法
    下一条:
    linux下零拷贝技术介绍
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • 在Linux系统中使用Iptables实现流量转发功能流程步骤(0个评论)
    • vim学习笔记-入门级需要了解的一些快捷键(0个评论)
    • 在centos7系统中实现分区并格式化挂载一块硬盘到/data目录流程步骤(0个评论)
    • 在Linux系统种查看某一个进程所占用的内存命令(0个评论)
    • Linux中grep命令中的10种高级用法浅析(0个评论)
    • 近期文章
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(0个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 欧盟关于强迫劳动的规定的官方举报渠道及官方举报网站(0个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf文件功能(0个评论)
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • 在go + gin中gorm实现指定搜索/区间搜索分页列表功能接口实例(0个评论)
    • 在go语言中实现IP/CIDR的ip和netmask互转及IP段形式互转及ip是否存在IP/CIDR(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • Laravel 11.15版本发布 - Eloquent Builder中添加的泛型(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-11
    • 2017-07
    • 2017-10
    • 2017-11
    • 2018-01
    • 2018-02
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-03
    • 2022-04
    • 2022-08
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-06
    • 2023-07
    • 2023-10
    • 2023-12
    • 2024-01
    • 2024-04
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客