Tuesday, May 29, 2012

The Android emulator is not starting, showing "invalid command-line parameter'


I made a simple "Hello World" program in Eclipse . I added nothing to a Java file and only added a text view in file main.xml as




//main.xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World"
/>
</LinearLayout>



And now when I run my program it shows the following in the console.




//console output
[2011-07-10 07:10:22 - demo] ------------------------------
[2011-07-10 07:10:22 - demo] Android Launch!
[2011-07-10 07:10:24 - demo] adb is running normally.
[2011-07-10 07:10:24 - demo] Performing com.demo.DemoActivity activity launch
[2011-07-10 07:10:25 - demo] Automatic Target Mode: launching new emulator with compatible AVD 'vishal'
[2011-07-10 07:10:25 - demo] Launching a new emulator with Virtual Device 'vishal'
[2011-07-10 07:11:06 - Emulator] invalid command-line parameter: Files\Android\android-sdk\tools/emulator-arm.exe.
[2011-07-10 07:11:07 - Emulator] Hint: use '@foo' to launch a virtual device named 'foo'.
[2011-07-10 07:11:07 - Emulator] please use -help for more information

//--------------------------------------------------------------------------------/



This shows my Android Virtual Device (AVD) could not start due to some reason. What can I do to fix this problem?


Source: Tips4all

10 comments:

  1. If your SDK location path in Eclipse is in C:\Program Files (x86)\ change to C:\PROGRA~2\.
    If you are running 32-bit Windows, C:\Program Files\, change the path to C:\PROGRA~1\.

    ReplyDelete
  2. There is currently a problem with R12 where the SDK location cannot contain any spaces.

    The default installation location is: C:\Programme Files(x86)\Android\android-sdk. They are currently fixing the problem but you can currently work around it by changing the SDK location path in eclipse to C:\PROGRA~2\Android\android-sdk.

    If you are running 32-bit Windows, change the path to C:\PROGRA~1\Android\android-sdk.

    ReplyDelete
  3. I'd suggest creating a directory junction named C:\Android pointing to the actual C:\Program Files (x86)\Android\android-sdk-windows\:

    MKLINK /J C:\Android "C:\Program Files (x86)\Android\android-sdk-windows\"


    and then setting the newly created junction as SDK Location for your Eclipse ADT Plugin (Eclipse menu\ Window\ Preference\ Android).
    This might help for a number of tools/ plugin too that have problems with spaces in paths.

    ReplyDelete
  4. NickC is correct. It is also worth pointing out that the SDK location is set in Eclipse > Window menu > Preferences > Android. If your folders are different you can check the 8.3 format of any folder with dir foldername /x at the command prompt.

    ReplyDelete
  5. I had this issue as well. The solution is (if you are on Windows as I am) to change the path to C:\PROGRA~1\Android\android-sdk-windows\.

    Assuming Program Files is the first directory with the word PROGRAM in it which it should be. This worked.

    ReplyDelete
  6. I started Task Manager, made sure adb.exe is closed (it locks some files)

    Create the folder C:\Android
    Moved folder + all files from C:\Program Files\android-sdk to C:\Android

    Edited C:\Documents and Settings\All Users\Start Menu\Programs\Android SDK Tools shortcuts.

    I considered uninstalling the SDK and re-installing, but for the life of me, where does it store the temp files?? I don't want to re-download the platforms, samples and doco that I have added to the SDK.

    ReplyDelete
  7. I had the same problem. I made it work with:

    "C:\Program Files (x86)\Android\android-sdk\tools\emulator-arm.exe" @foo


    foo is the name of your virtual device.

    ReplyDelete
  8. Remember to run "android update avd -n avd_name" after change in Android SDK path.

    ReplyDelete
  9. As an alternative to the PROGRA~2 method (which is not working for example in IntelliJ IDEA), you can create a symbolic link.

    It can be named, for example, prg to Program Files (run mklink /? from the command line to learn how to do it). Then run the emulator as C:\prg\Android\android-sdk\tools\emulator.exe. Also change the path to SDK/emulator in your IDE.

    ReplyDelete
  10. This don't work since Andoid SDK R12 update.
    I think is because SDK don't find the Java SDK Path.
    You can solve that by adding the Java SDK Path in your PATH environment variable.

    ReplyDelete