您的位置:首页 > 移动开发 > Android开发

error target id is not valid use android list targets to get the target ids

2014-02-11 16:39 876 查看
Launching from Eclipse/ADT

If you are developing in Eclipse and have already installed the ADT Plugin, follow these steps to access the Android SDK and ***D Manager tool:

1. Open Eclipse

2. Select Window > Android SDK and ***D Manager.

Launching from the setup script (Windows only)

For Windows only, the SDK includes a script that invokes the Android SDK and ***D Manager. To launch the tool using the script, double-click "SDK Setup.exe" at the root of the the SDK directory.

Launching from a command line

In all development environments, follow these steps to access the Android SDK and ***D Manager tool from the command line:

1. Navigate to the <sdk>/tools/ directory.

2. Execute the android tool command with no options.

$ android

Installing SDK Components

Important: Before you install SDK components, we recommend that you disable any antivirus programs that may be running on your computer.

Follow these steps to install new SDK components in your environment:

1. Launch the Android SDK and ***D Manager as described in the section above.

2. Select Available Packages in the left panel. This will reveal all of the components that are currently available for download from the SDK repository.

3. Select the component(s) you'd like to install and click Install Selected. If you aren't sure which packages to select, read Which components do I need?.

4. Verify and accept the components you want and click Install Accepted. The components will now be installed into your existing Android SDK directories.

New platforms are automatically saved into the <sdk>/platforms/ directory of your SDK; new add-ons are saved in the <sdk>/add-ons/ directory; samples are saved in the <sdk>/samples/android-<level>/; and new documentation is saved in the existing <sdk>/docs/ directory (old docs are replaced).

yelei@ubuntu:/android/myandroid/sdk/tools$ ./android

Starting Android SDK and ***D Manager

No command line parameters provided, launching UI.

See 'android --help' for operations from the command line.

yelei@ubuntu:/android/myandroid/sdk/tools$ ./android create avd -n NO1 -t 1

Android 2.2 is a basic Android platform.

Do you wish to create a custom hardware profile [no]yes

yelei@ubuntu:/android/myandroid/sdk/tools$ ./android list avd

Available Android Virtual Devices:

Name: NO1

Path: /home/yelei/.android/avd/NO1.avd

Target: Android 2.2 (API level 8)

Skin: HVGA

yelei@ubuntu:/android/myandroid/sdk/tools$ ./emulator –avd NO1

invalid command-line parameter: –avd.

Hint: use '@foo' to launch a virtual device named 'foo'.

please use -help for more information

yelei@ubuntu:/android/myandroid/sdk/tools$ ./emulator @NO1

之上是从网站上摘抄的

从中看出问题出在
android 这一命令上

输入
android 命令后 我的出现了swt.jar 版本的错误 我使用的是32位的

Cannot
load 32-bit SWT libraries on 64-bit JVM

下载相对应版本的 swt

或者在android 编译路径 中 prebuilts\tools\linux-x86_64\swt 换到环境变量中

然后android 命令确保没有问题

输入android list targets 如果为空说明可用的模拟器是空

Android 2.3下只要设置了ANDROID_PRODUCT_OUT环境变量emulator就可以使用了,但是在android 4.1下就不能使用了

只有刚刚make结束的时候的终端可以直接运行,新开一个终端就不行了,出现以下提示:

emulator: ERROR: You did not specify a virtual device name, and the system

directory could not be found.

If you are an Android SDK user, please use '@<name>' or '-avd <name>'

to start a given virtual device (see -help-avd for details).

Otherwise, follow the instructions in -help-disk-images to start the emulator

又不想去装sdk所以就去查代码了

在/externel/qemu/android/main-common.c下发现

AvdInfo* create***D(AndroidOptions* opts, int* inAndroidBuild)函数

809 android_build_root = getenv("ANDROID_BUILD_TOP");

810 if (android_build_root == NULL || android_build_root[0] == 0)

811 break;

在上面两行中,如果android_build_root为0就直接跳出循环了

但是android_build_out = out;

在这之后

所以,829行 if (opts->avd == NULL && !android_build_out)

就都为真了

不知道是不是bug。

其实,可以将android_build_out = out;提到前面来

这样判断就不会进入,如果是非要大家设置ANDROID_BUILD_TOP环境变量

那也应该先执行以下

813 if (!path_exists(android_build_root)) {

814 derror("Can't find the Android build root '%s'\n"

815 "Please check the definition of the ANDROID_BUILD_TOP variable.\n"

816 "It should point to the root of your source tree.\n",

817 android_build_root );

818 exit(2);

819 }

再跳出循环

目前的解决方式是设置ANDROID_BUILD_TOP环境变量

1、在SDK Manager下Tools->Options打开了SDK Manager的Settings,

选中“Force https://… sources to be fetched using http://…”,强制使用http协议。
2、修改host文件,添加下面两行

#google_android更新

203.208.46.146 dl.google.com

203.208.46.146 dl-ssl.google.com




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐