安卓开发----创建一个安卓工程

一个安卓工程包含所有的文件,这些文件组成你安卓应用的源代码。安卓SDK工具是的创建安卓工程是非常容易的,并且工程使用默认的目录和文件。

这个节课讲展示如何创建一个新的工程,使用ECLIPSE,或使用SDK工具的命令行。

下面使用抓图进行说明,我们使用默认的配置,基本不做任何修改,后面会将根据具体的需求而修改这些相关配置


一 使用ECLIPSE











二 使用命令行

C:\Users\zhangdong>d:

D:\>cd adt

D:\adt>dir
 驱动器 D 中的卷没有标签。
 卷的序列号是 00DF-A940

 D:\adt 的目录

2013/07/29  15:50    <DIR>          .
2013/07/29  15:50    <DIR>          ..
2013/08/23  17:20    <DIR>          eclipse
2013/08/14  19:16    <DIR>          sdk
2013/07/29  15:50           357,814 SDK Manager.exe
               1 个文件        357,814 字节
               4 个目录 379,928,743,936 可用字节

D:\adt>cd sdk

 D:\adt\sdk 的目录

2013/08/14  19:16    <DIR>          .
2013/08/14  19:16    <DIR>          ..
2013/08/14  19:16    <DIR>          add-ons
2013/07/29  15:51    <DIR>          build-tools
2013/07/29  15:52    <DIR>          extras
2013/07/29  15:51    <DIR>          platform-tools
2013/07/29  15:51    <DIR>          platforms
2013/07/29  15:52    <DIR>          system-images
2013/07/29  15:50    <DIR>          tools
               0 个文件              0 字节
               9 个目录 379,928,743,936 可用字节


D:\adt\sdk>cd tools

D:\adt\sdk\tools>
C:\Users\zhangdong>d:
D:\>cd adt

D:\adt>dir
 驱动器 D 中的卷没有标签。
 卷的序列号是 00DF-A940

 D:\adt 的目录

2013/07/29  15:50    <DIR>          .
2013/07/29  15:50    <DIR>          ..
2013/08/23  17:20    <DIR>          eclipse
2013/08/14  19:16    <DIR>          sdk
2013/07/29  15:50           357,814 SDK Manager.exe
               1 个文件        357,814 字节
               4 个目录 379,928,743,936 可用字节

D:\adt>cd sdk

 D:\adt\sdk 的目录


2013/08/14  19:16    <DIR>          .
2013/08/14  19:16    <DIR>          ..
2013/08/14  19:16    <DIR>          add-ons
2013/07/29  15:51    <DIR>          build-tools
2013/07/29  15:52    <DIR>          extras
2013/07/29  15:51    <DIR>          platform-tools
2013/07/29  15:51    <DIR>          platforms
2013/07/29  15:52    <DIR>          system-images
2013/07/29  15:50    <DIR>          tools
               0 个文件              0 字节
               9 个目录 379,928,743,936 可用字节

D:\adt\sdk>cd tools

D:\adt\sdk\tools>

D:\adt\sdk\tools>android list targets
Available Android targets:
----------
id: 1 or "android-18"
     Name: Android 4.3
     Type: Platform
     API level: 18
     Revision: 1
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, W
XGA720, WXGA800, WXGA800-7in
     ABIs : armeabi-v7a


两次失败执行,ID不对,和上面的id相同


D:\adt\sdk\tools>android create project --target 19 --path  d:\anzhuo\MyFirstApp
\  --activity MainActivity --package com.example.myfirstapp
Error: Target id is not valid. Use 'android.bat list targets' to get the target
ids.

D:\adt\sdk\tools>android create project --target 18 --path  d:\anzhuo\MyFirstApp
\  --activity MainActivity --package com.example.myfirstapp
Error: Target id is not valid. Use 'android.bat list targets' to get the target
ids.

D:\adt\sdk\tools>android create project --target android-18 --path  d:\anzhuo\My
FirstApp\  --activity MainActivity --package com.example.myfirstapp
Created directory D:\anzhuo\MyFirstApp\src\com\example\myfirstapp
Added file d:\anzhuo\MyFirstApp\src\com\example\myfirstapp\MainActivity.java
Created directory D:\anzhuo\MyFirstApp\res
Created directory D:\anzhuo\MyFirstApp\bin
Created directory D:\anzhuo\MyFirstApp\libs
Created directory D:\anzhuo\MyFirstApp\res\values
Added file d:\anzhuo\MyFirstApp\res\values\strings.xml
Created directory D:\anzhuo\MyFirstApp\res\layout
Added file d:\anzhuo\MyFirstApp\res\layout\main.xml
Created directory D:\anzhuo\MyFirstApp\res\drawable-xhdpi
Created directory D:\anzhuo\MyFirstApp\res\drawable-hdpi
Created directory D:\anzhuo\MyFirstApp\res\drawable-mdpi
Created directory D:\anzhuo\MyFirstApp\res\drawable-ldpi
Added file d:\anzhuo\MyFirstApp\AndroidManifest.xml
Added file d:\anzhuo\MyFirstApp\build.xml
Added file d:\anzhuo\MyFirstApp\proguard-project.txt

D:\adt\sdk\tools>


查看目录,产生工程文件




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值