博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[APP] Android 开发笔记 001-环境搭建与命令行创建项目
阅读量:6856 次
发布时间:2019-06-26

本文共 6492 字,大约阅读时间需要 21 分钟。

1. 安装JDK,SDK

  JDK       http://www.oracle.com/technetwork/java/javase/downloads/index.html

  Android SDK  

           https://dl.google.com/android/android-sdk_r24.4.1-windows.zip (No installer)

           https://dl.google.com/android/installer_r24.4.1-windows.exe

            

  Ant tool  http://ant.apache.org/bindownload.cgi

 

Android SDK在线更新镜像服务器

  1. 南阳理工学院镜像服务器地址:

    mirror.nyist.edu.cn 端口:80

  2. 中国科学院开源协会镜像站地址:

    • IPV4/IPV6: mirrors.opencas.cn 端口:80

    • IPV4/IPV6: mirrors.opencas.org 端口:80

    • IPV4/IPV6: mirrors.opencas.ac.cn 端口:80

  3. 上海GDG镜像服务器地址:

    sdk.gdgshanghai.com 端口:8000

  4. 北京化工大学镜像服务器地址:

    • IPv4: ubuntu.buct.edu.cn/ 端口:80

    • IPv4: ubuntu.buct.cn/ 端口:80

    • IPv6: ubuntu.buct6.edu.cn/ 端口:80

  5. 大连东软信息学院镜像服务器地址:

    mirrors.neusoft.edu.cn 端口:80

  6. 腾讯Bugly 镜像:

    https://dsx.bugly.qq.com/repository/1

    腾讯镜像使用方法:

2. 设置环境变量:

  将下面两个加入系统环境变量表 Path键值中:

  \Android\sdk\platform-tools

  \Android\sdk\tools

  设置Ant

    ANT_HOME :指的是apache-ant-1.8.4-bin.zip的解压文件(apache-ant-1.8.4)所在的位置;

        我把这个文件放在D盘,所以我这里设置的ant_home就是 ant_home=D:\apache-ant-1.8.2;

      path路径设置为:PATH = %ANT_HOME%/bin; %ANT_HOME%/lib即可

3. 使用命令行创建Android应用:

  1) 进入需要创建Android应用的文件夹:

    cd D:\Android Development

  2)在当前路径下,创建Android 项目

  android create project -n MySecApp -p android_Sec -a MyActivitySec -k Com.test.mysecapp -t 2

    命令行说明:

      -n 表示 name 跟项目名称

         -p 表示 path 跟工作空间
         -a 表示 创建的Activity的名称
         -k 表示 package 跟包名称
         -t 表示 target 跟target id
        (*target id * 可以通过 android list targets 查看,系统将列出所有的下载好的可用的 android 版本号)

  

  

  3)使用命令给APK打包

          

    

     

  ant debug 的过程:

  

D:\Android Development>ant -versionApache Ant(TM) version 1.9.7 compiled on April 9 2016D:\Android Development>cd android_SecD:\Android Development\android_Sec>ant debugBuildfile: D:\Android Development\android_Sec\build.xml-set-mode-check:-set-debug-files:-check-env: [checkenv] Android SDK Tools Revision 25.1.2 [checkenv] Installed at C:\Users\SDSC\AppData\Local\Android\sdk-setup:     [echo] Project Name: MySecApp  [gettype] Project Type: Application-set-debug-mode:-debug-obfuscation-check:-pre-build:-build-setup:[getbuildtools] Using latest Build Tools: 23.0.2     [echo] Resolving Build Target for MySecApp...[gettarget] Project Target:   Google APIs[gettarget] Vendor:           Google Inc.[gettarget] Platform Version: 6.0[gettarget] API level:        23[gettarget] WARNING: No minSdkVersion value set. Application will install on all Android versions.     [echo] ----------     [echo] Creating output directories if needed...    [mkdir] Created dir: D:\Android Development\android_Sec\bin\res    [mkdir] Created dir: D:\Android Development\android_Sec\bin\rsObj    [mkdir] Created dir: D:\Android Development\android_Sec\bin\rsLibs    [mkdir] Created dir: D:\Android Development\android_Sec\gen    [mkdir] Created dir: D:\Android Development\android_Sec\bin\classes    [mkdir] Created dir: D:\Android Development\android_Sec\bin\dexedLibs     [echo] ----------     [echo] Resolving Dependencies for MySecApp...[dependency] Library dependencies:[dependency] No Libraries[dependency][dependency] ------------------     [echo] ----------     [echo] Building Libraries with 'debug'...   [subant] No sub-builds to iterate on-code-gen:[mergemanifest] Merging AndroidManifest files into one.[mergemanifest] Manifest merger disabled. Using project manifest only.     [echo] Handling aidl files...     [aidl] No AIDL files to compile.     [echo] ----------     [echo] Handling RenderScript files...     [echo] ----------     [echo] Handling Resources...     [aapt] Generating resource IDs...     [echo] ----------     [echo] Handling BuildConfig class...[buildconfig] Generating BuildConfig class.-pre-compile:-compile:    [javac] Compiling 3 source files to D:\Android Development\android_Sec\bin\classes    [javac] 警告: [options] 源值1.5已过时, 将在未来所有发行版中删除    [javac] 警告: [options] 目标值1.5已过时, 将在未来所有发行版中删除    [javac] 警告: [options] 要隐藏有关已过时选项的警告, 请使用 -Xlint:-options。    [javac] 3 个警告-post-compile:-obfuscate:-dex:      [dex] input: D:\Android Development\android_Sec\bin\classes      [dex] Converting compiled files and external libraries into D:\Android Development\android_Sec\bin\classes.dex...-crunch:   [crunch] Crunching PNG Files in source dir: D:\Android Development\android_Sec\res   [crunch] To destination dir: D:\Android Development\android_Sec\bin\res   [crunch] Processing image to cache: D:\Android Development\android_Sec\res\drawable-hdpi\ic_launcher.png => D:\Android Development\android_Sec\bin\res\drawable-hdpi\ic_launcher.png   [crunch]   (processed image to cache entry D:\Android Development\android_Sec\bin\res\drawable-hdpi\ic_launcher.png: 87% size of source)   [crunch] Processing image to cache: D:\Android Development\android_Sec\res\drawable-ldpi\ic_launcher.png => D:\Android Development\android_Sec\bin\res\drawable-ldpi\ic_launcher.png   [crunch]   (processed image to cache entry D:\Android Development\android_Sec\bin\res\drawable-ldpi\ic_launcher.png: 0% size of source)   [crunch] Processing image to cache: D:\Android Development\android_Sec\res\drawable-mdpi\ic_launcher.png => D:\Android Development\android_Sec\bin\res\drawable-mdpi\ic_launcher.png   [crunch]   (processed image to cache entry D:\Android Development\android_Sec\bin\res\drawable-mdpi\ic_launcher.png: 78% size of source)   [crunch] Processing image to cache: D:\Android Development\android_Sec\res\drawable-xhdpi\ic_launcher.png => D:\Android Development\android_Sec\bin\res\drawable-xhdpi\ic_launcher.png   [crunch]   (processed image to cache entry D:\Android Development\android_Sec\bin\res\drawable-xhdpi\ic_launcher.png: 85% size of source)   [crunch] Crunched 4 PNG files to update cache-package-resources:     [aapt] Creating full resource package...-package:[apkbuilder] Current build type is different than previous build: forced apkbuilder run.[apkbuilder] Creating MySecApp-debug-unaligned.apk and signing it with a debug key...-post-package:-do-debug: [zipalign] Running zip align on final apk...     [echo] Debug Package: D:\Android Development\android_Sec\bin\MySecApp-debug.apk[propertyfile] Creating new property file: D:\Android Development\android_Sec\bin\build.prop[propertyfile] Updating property file: D:\Android Development\android_Sec\bin\build.prop[propertyfile] Updating property file: D:\Android Development\android_Sec\bin\build.prop[propertyfile] Updating property file: D:\Android Development\android_Sec\bin\build.prop-post-build:debug:BUILD SUCCESSFULTotal time: 12 secondsD:\Android Development\android_Sec>

  4)生成的Apk

  

 

转载地址:http://qayyl.baihongyu.com/

你可能感兴趣的文章
《HTML5游戏编程核心技术与实战》一2.4 坐标变换
查看>>
《互联网产品设计》一2.5 写代码,让产品可以使用
查看>>
大数据的真正价值在哪里?
查看>>
最新版AlphaGo(Master)的60胜预示着人类将是一种过时的算法?
查看>>
美使馆9年pm2.5数据分析:雾霾到底是不是加重了?
查看>>
《嵌入式Linux开发实用教程》——4.3 块设备驱动
查看>>
《Maven官方文档》POM文件(二)
查看>>
Apache Storm 官方文档 —— 配置开发环境
查看>>
企业IT架构转型之道:阿里巴巴中台战略思想与架构实战. 2.5 为真正发挥大数据威力做好储备...
查看>>
如何通过 MySQL 的二进制日志恢复数据库数据
查看>>
【科普】数字货币的基石--区块链
查看>>
深入实践Spring Boot1.2.1 使用Maven新建项目
查看>>
Request、Request.Params、Request.QueryString、Request.form的区别
查看>>
《Hadoop MapReduce性能优化》一导读
查看>>
Spark修炼之道(基础篇)——Linux大数据开发基础:第四节:Linux文件系统(二)...
查看>>
【Spark Summit East 2017】使用Spark进行可伸缩的元基因组分析
查看>>
一张图清晰追溯数据库的发展历程(1962-2016)
查看>>
【D3.js 学习总结】10、D3布局-力学图
查看>>
java 内部类(inner class)详解
查看>>
G1 收集器
查看>>