使用命令行创建Android项目

    xiaoxiao2021-03-25  104

    文章来源:http://hukai.me/android-training-course-in-chinese/basics/firstapp/creating-project.html

    一、创建Android 应用

    1. 打开命令行切换到SDK根目录下;

    2. 打印出我们所有的Android SDK中下载好的可用Android platforms,找想要创建项目的目标platform,记录该platform对应的Id,推荐使用最新的platform。

    tools/android list targets

    3. 执行:

    android create project --target <target-id> --name MyFirstApp --path <path-to-workspace>/MyFirstApp --activity MyActivity --package com.example.myfirstapp

    替换<target-id>为上一步记录好的Id,替换<path-to-workspace>为我们想要保存项目的路径。

    二、运行Android应用

    1.安装ant。

    a.从http://ant.apache.org/bindownload.cgi下载ant。

    b.解压。

    c.配置环境变量。配置ANT_HOME,然后把%ANT_HOME%/bin加到PATH的环境变量。

    d.运行ant。 查看是否安装成功。

    2.编译工程生成debug key签名的apk打包文件,命令 ant debug,bin目录变化。

    3.安装apk。adb install bin/xx-debug.apk 4.点击手机上的APP并运行。

    注:adb不是内部命令的解决方法,将adb.exe的目录加到PATH变量。

    转载请注明原文地址: https://ju.6miu.com/read-15405.html

    最新回复(0)