2.Android-sdk directory introduction, ADT use reports, create helloworld

1.android commonly used term introduced

  • ADT:   ADT for Eclipse plug-ins. Between Eclipse and SDK played a role of a bridge.
  • SDK: Software Development Kit (Soft Development Kit) , which provides tools used in libraries and other Android developers for developers
  • The JDK:  java development kit that provides tools and java java libraries and runtime environment.
  • NDK: Native Development Kit, to help developers quickly develop C (or C ++) dynamic libraries and automatically packaged so and java applications together into apk (later re-use)

2.sdk Contents Introduction

sdk directory as follows:

 

  • add-ons:     third-party files required for Android development
  • build-tools: build tools, such as build-tools / android-xx / aapt.exe is packed Android resource tool, Build-Tools / Android-xx / dx.bat sucked class file documents into dex tool
  • docs:  Android documents, including the Development Guide, API, etc.
  • extras: The android store subdirectory under the Android support library, for example, contains v4, v7, v13 package, provided the intel subdirectory is hardware accelerated accessory kit (if it is core processor, you can speed up the emulator to run )
  • platforms:   storage compile different versions of Android API, such as user 4.3 (18API) version compiled APP, it is called platforms / android-18 / android.jar to compile.
  • platform-tools: store a number of common tools, such as adb.exe etc.
  • sample: The sample project provided by the official Android
  • Sources: SDK source code
  • system-images: the system image (image file simulator)
  • temp:   cache directory
  • tools: Some important tool to use when programming. For example: DDMS Android debugging tools, etc.

 

3.  ADT-sdkManager Introduction

Android Software Development Kit manager, like a bridge, connecting local and server, downloaded from the server to the local Android development tools required.

  And AVD Manager is an Android virtual drive manager, is mainly used to create the Android emulator (ie phone simulator). Of course, the desired image by Andrews simulator SDK Manager to download.

  对于SDK Manager和AVD Manager的使用,还需要一个基础工具包tools提供支持(必须安装,如下图所示)

如下图所示(参考知乎https://www.zhihu.com/question/31935836):

3.1 下载之前需要设置代理

在使用sdkManager下载包之前,我们还需要设置代理,否则会导致下载失败.

点击Tools->Options:

 

代理设置如下:

 

 

4.  ADT-Android Virtual Device(AVD)虚拟机介绍

Android Virtual Device表示用来运行应用程序的安卓虚拟设备.

进入Eclipse页面。选择工具栏中的Android Virtual Device Manager,如下图:

 

然后弹出AVD对话框,选择点击右边的new按钮,来创建模拟器机型,如下图所示:

 

然后弹出如下图所示:

  • AVD name : 是要填写的虚拟机名称,随便取就可以了
  • Device : 这里是要选择模拟的设备,个人建议选择320*480,因为显示越大,虚拟机内存越大
  • Target : 是选择模拟器的安卓系统的版本
  • CPI/ABi : 模拟器模拟的CPU型号.
  • keyboard: 默认勾选,表示支持键盘外部输入.
  • skin : 默认勾选,表示模拟器表现的样式,不同的皮肤,呈现的界面和操作按钮都不一样。
  • Front camera 和 back camera : 表示是否模拟前置和后置摄像头,建议不选,如果要使用摄像头,一般用真机.
  • RAM :  模拟器内存,512M或者1024M就行.
  • VM Heap :  是模拟器每一个应用的最大内存空间,16表示每个应用有16M。
  • Internal Storage :  模拟器模拟的手机芯片存储容量的大小,一般用来存放操作系统的,模拟器一般512M即可
  • SD Card :  模拟手机SD卡
  • Snapshot : 表示模拟器使不使用截图启动,这个功能可能会造成模拟器无法启动,但是勾选上模拟器的启动会加快,默认不勾选
  • Use Host GPU :  表示是否使用PC机的GPU模拟手机显卡,这里建议不勾选.如果不做耗显卡之类的应用,则一般不选.

配置完成并点击OK后,我们则点击AVD对话框的start..按钮:

 

然后我们在点击下图的Launch则可以启动模拟器了:

 

启动后,如下图所示:

 

 

5.  ADT-ddms透视图介绍

ddms位于ADT右上角,点击DDMS,如下图所示:

 

这是通过ADB(Android Debug Bridge)安卓调试桥来连接在一起的.

如果连接失败或者异常了,可以关闭后台adb.exe,然后点击reset adb来复位ADB,即可恢复,如下两图所示:

 

 

5.1使用屏幕截图

操作如下所示:

 

 

5.2通过file explorer查看在线设备的文件目录

如下图所示:

 

常用路径

  • data/app : 存放apk应用安装数据
  • data/data : 存放app应用数据
  • mnt/sdcard : sd卡挂载的目录根路径

5.3 emulate Control虚拟控制器

如下图所示:

 

  • unregistered : 注销的
  • home : 本地
  • roaming : 漫游
  • searching : 搜索  
  • denied : 注销

如下图所示,如果我们设置为注销的:

 

如果设置为home,则有信号:

 

 

5.4 emulate Control之呼入电话示例

设置拨打号码为110,然后点击call后,模拟器则会显示110来电:

 

 

5.5 emulate Control之设置虚拟机坐标位置

 

 

6.创建helloworld

万事以hello world开头,首先创建project,如下图所示:

 

首先需要设置名字,如下图所示:

 

  • Application Name和Project Name : 支持中文,名称保持一致
  • Package Name :  包名、不支持中文,一般是公司域名倒写+项目名字(com.xxx.project)
  • Minimum SDK :  表示该APP支持的最低版本是多少,如果低于4.0则会安装失败
  • Target SDK :  指要运行的目标版本
  • Compile With :  表示通过哪个API版本来进行编译,这里选择API18,则将调用sdk/platforms/android-18/android.jar来进行编译.
  • Theme :  应用程序主题,共有None、Holo Dark(黑)、 Holo Light(亮)、 Holo Light with dark action bar

设置名字后,点击next,即设置项目路径,如下图所示:

 

设置项目路径后,点击next,即设置应用图标,如下图所示:

 

设置应用图标后,点击next,即设置activity样式,我们选择blank activity(空的)即可,如下图所示:

 

设置activity样式后,点击next,即设置activity名称和layout布局名称 ,如下图所示:

 

点击finish即创建完成,右击run as,即可运行helloworld,如下图所示:

 

 

下章开始分析helloworld程序

Guess you like

Origin www.cnblogs.com/lifexy/p/12059503.html