我正在尝试从命令行创建一个新的android项目。我正在关注http://developer.android.com/的教程。在本教程中,首先他们要求我使用./android list targets
命令列出我系统上安装的所有可用平台。这给了我以下结果,
irfan@outerheavenY500Ubuntu:~/Android/Sdk/tools$ ./android list targets
Available Android targets:
----------
id: 1 or "android-21"
Name: Android 5.0.1
Type: Platform
API level: 21
Revision: 2
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
Tag/ABIs : android-wear/armeabi-v7a, android-wear/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 2 or "Google Inc.:Google APIs:21"
Name: Google APIs
Type: Add-On
Vendor: Google Inc.
Revision: 1
Description: Android + Google APIs
Based on Android 5.0.1 (API level 21)
Libraries:
* com.android.future.usb.accessory (usb.jar)
API for USB Accessories
* com.google.android.media.effects (effects.jar)
Collection of video effects
* com.google.android.maps (maps.jar)
API for Google Maps
Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
Tag/ABIs : google_apis/x86
然后我尝试执行以下命令来创建一个新项目,
./android create project --target 1 --name MyFirstApp2 \ --path /home/irfan/AndroidProjects/MyFirstApp2 --activity MyActivity \ --package com.example.myfirstapp2
但是这给了我以下错误Error: Argument 'com.example.myfirstapp2' is not recognized.
从教程我遵循以下命令结构来创建一个新项目
./android create project --target <target-id> --name MyFirstApp \
--path <path-to-workspace>/MyFirstApp --activity MyActivity \
--package com.example.myfirstapp
如果我正确地遵循了这个结构,那么有人能指出我还有什么不对吗?
答案 0 :(得分:2)
删除反斜杠。您还想add the path ~/Android/Sdk/tools
到您的$PATH
。这样您就可以从任何目录中调用android
和adb
。
cd
PATH=$PATH:~/Android/Sdk/tools
export PATH
android create project --target 1 --name MyFirstApp2 --path ./MyFirstApp2 --activity MyActivity --package com.example.myfirstapp2
答案 1 :(得分:2)
从命令中删除\
个字符。这些是您不需要的新线路连接器。您的命令应如下所示:
./android create project --target 1 --name MyFirstApp2 --path /home/irfan/AndroidProjects/MyFirstApp2 --activity MyActivity --package com.example.myfirstapp2