Error when running PhoneGap for Android

78 views
Skip to first unread message

James Lee

unread,
Jan 12, 2014, 1:02:53 PM1/12/14
to app-...@googlegroups.com
Hi folks!

I followed the instructions on this web page (https://dl.dropboxusercontent.com/u/348446/trainings/android2.html) to install PhoneGap and Android Studio (v0.3.2) on my Windows 8 PC.  However, when I run "phonegap run android" on the command line I get the following error:

"Error: Please install Android target 19 (the Android newest SDK). Make sure you have the latest Android tools installed as well. Run "android" from your command-line to install/update any missing SDKs or tools."

Can anyone please help provide some clear instructions on what steps I should follow to properly resolve this issue? 

Thanks!!

-James

Michael Malloy

unread,
Jan 13, 2014, 1:02:11 PM1/13/14
to app-...@googlegroups.com
Hello James,

I had the same experience using those instructions.  To get past it, I did the following:

1. Apache Ant needed to be installed on my system.  Download from http://ant.apache.org.  Unzip and untar the distribution and copy the folder to something like c:\Program Files\ant.  Then, add c:\Program Files\ant\bin to your path
2. Make sure that JAVA_HOME is set to the new JDK that was downloaded.  In my case, that was c:\Program Files\Java\jdk1.7.0_45
3. This may be an optional step, but I added the path to the java.exe executable to my path
4. From the command line, run "android".  It should launch a window that allows you to update your system.  Choose to make the recommended updates.  One thing that I needed to do was to set the permissions on my c:\Program Files (x86)\Android\android-studio to allow users to modify it.  Otherwise, you may have permissions violation errors when running the android application

Test the ant executable by running "ant -version" from the command line.   That should return the installed version (current version is 1.9.3).

5. If you are using an emulator, setup an AVD using the instructions at http://developer.android.com/tools/devices/index.html.  Otherwise, plug in an Android device and choose to allow debugging.

When all this is done, run "phonegap run android".  Phonegap should compile the project and first look for a device to run it on and if it doesn't find one, it will try to open it in an emulator.

James Lee

unread,
Jan 13, 2014, 2:53:43 PM1/13/14
to app-...@googlegroups.com
Hi Michael,

I'm not sure if my previous reply went through correctly, so I'm re-typing it up again. First of all, thanks very much for responding to my post.  When running step 4 of your instructions (i.e., running "android" at the command line), I am returned with the usage instructions for "java".  See the snippet below.  Do you have any thoughts as to why I may be seeing this behavior?  I'm thinking it's pretty important to figure out this issue before I move forward.

C:\>android
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32          use a 32-bit data model if available
    -d64          use a 64-bit data model if available
    -server       to select the "server" VM
    -hotspot      is a synonym for the "server" VM  [deprecated]
                  The default VM is server.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument

    -splash:<imagepath>
                  show splash screen with specified image
ore details.


Thanks!

-James

Michael Malloy

unread,
Jan 14, 2014, 2:33:28 PM1/14/14
to app-...@googlegroups.com
The problem has something to do with android.bat, which for me is located at c:\Program Files (x86)\Android\android-studio\sdk\tools.  Near the end of there is a line that starts with 

call %java_exe% %REMOTE_DEBUG% ...

It's likely that one or more of the environment variables on that line is blank or wrong, causing the java executable to display its usage text.  I believe when you get that line working, the update app will launch and you'll be able to update your system.

James Lee

unread,
Jan 14, 2014, 2:52:10 PM1/14/14
to app-...@googlegroups.com
Thanks Michael.  My android.bat file is located in the same location. Looks like I have some playing around to do to figure out what's wrong with that line.  These kinds of things never seem to work fully the first time, do they :).

Thanks again for your help.

-James

James Lee

unread,
Mar 13, 2014, 4:42:31 PM3/13/14
to app-...@googlegroups.com
Hi Michael,

I was finally able to resolve the issue previously described when running "android" from the command line.  I also followed instructions from your steps 4 and 5 about updating my system with the latest android updated and setting up an AVD.  Finally, I attempted to run the android emulator by executing "phonegap run android" on the command line.  Things seem to go well until it hits the following error when trying to install the app onto the emulator:

[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
[phonegap] trying to install app onto device
[phonegap] no device was found
[phonegap] trying to install app onto emulator
   [error] An error occurred while emulating/deploying the android project.
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:980:11)
    at Process.ChildProcess._handle.onexit (child_process.js:771:34)


Have you ever come across this issue?  If so, any thoughts on how to resolve?  I will say that there's not much to the app I'm trying to install.  I just created it following the instructions on this page (Step 6) https://dl.dropboxusercontent.com/u/348446/trainings/android2.html.  Any insights you have would be greatly appreciated.

Thanks!

-James

Michael Malloy

unread,
Mar 14, 2014, 12:54:03 PM3/14/14
to app-...@googlegroups.com
Hello James,

I'm sorry you are having problems getting your Android application to launch.  My suggestion is to investigate if your emulator is properly setup and running correctly.

Phonegap is a viable option for Android development and we teach classes in it.  For anyone interested in starting out programming native Android applications, the following link may be interesting: https://class.coursera.org/android-001.  Usergrid will work with either native Android apps or Phonegap/HTML5.
Reply all
Reply to author
Forward
0 new messages