View
 

Getting started with Android PhoneGap in Eclipse

Page history last edited by Sim Ismail 1 wk ago

This guide will help you setup your first android project. The first thing to do is to download and install all the required dependencies.

 

Please contribute platform specific instructions where needed. Some cleanup wouldn't hurt either.

 

Installing dependencies

 

1. Java JDK

If you do not already have the java JDK installed on you'r system, install the Java SE Development Kit - JDK 6 from here:
http://java.sun.com/javase/downloads/index.jsp

 

If you're running Windows this is a standard installer file, just follow the on screen instructions for installation.

 

2. Eclipse

Install the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads/. This a ZIP archive file, extract the folder “eclipse”. Most other flavors of Eclipse (like Aptana or platform specific builds) will also work, provided that you install all the necessary Eclipse plug-ins.

 

3. Android SDK

Install the Android SDK Package from here:

http://developer.android.com/sdk/index.html 

 

Extract the downloaded archive and place it somewhere you'll remember and add the tools sub directory your PATH. Additional information and instructions for adding the Android SDK to your PATH can be found at:
http://developer.android.com/sdk/installing.html

 

Be sure to do the following (WINDOWS):

  1. Add android SDK to your Path
  2. Add android sdk tools (\android-sdk-windows\tools) to your path. This is necessary ruby to find the command "android create project" later on.

 

4. ADT Plug-in for Eclipse

Install the ADT Plug-in for Eclipse as described here: 

http://developer.android.com/sdk/eclipse-adt.html

 

5. Adding Android SDK components

Install at least the required Android SDK components using the Eclipse ADT plug-in, as described here: 

http://developer.android.com/sdk/adding-components.html 

 

You can also launch the ADT tool by running android in your terminal.

 

To verify your installation of Eclipse, Android SDK, ADT, and Java, you can build a sample “Hello World” application using the instructions located here:

http://developer.android.com/guide/tutorials/hello-world.html

 

6. Apache ANT

 

  • Windows - download and unzip Apache ANT and add it to your PATH http://ant.apache.org/index.html.
  • OS X - it comes with XCode otherwise "sudo port install apache-ant".

 

7. Ruby

 

 

8. Installing PhoneGap

Now make sure you download the latest version of PhoneGap here: 

http://github.com/phonegap/phonegap-android.

 

You can use git to download the source or press the download source button under the search bar.

 

Next run the following command from the phonegap-android folder. This will create a PhoneGap.jar file and create a basic Android Eclipse project in the output path that can then be opened in Eclipse.

 

    ruby .\droidgap "[android_sdk_path]" [name] [package_name] "[www]" "[path]"

 

    android_sdk_path ... The path to your Android SDK install. (Must use forward slashes (/) in path)

    name ...................... The name of your application.

    package_name ....... The name of your package (For example: com.nitobi.demo)

    www ...................... The path to your www folder. (Wherein your HTML, CSS and JS app is.)

    path ...................... The path to generate the application. (CANNOT be inside ANY Eclipse workspace) (Must use forward slashes (/) in path)

 

You should get a message in your terminal saying completed!

 

Some notes:

 

  • Your path cannot be inside any Eclipse workspace. *See note for Step 9
  • Make sure the path you set to generate the application doesn't exist
  • For the www folder, phonegap-android comes with a folder called example that includes some sample html, css and js.
  • I found I was getting errors for not having set android or ant in my path. Make sure you followed the earlier steps. 
  • When pointing to a directory, you need to have quotes around the path "C:/mobile/......"
  • While in the command prompt, use the forward slash ( / )and not the back slash ( \ ).  E.g. The android_sdk_path argument must use forward slashes (/).
  • Make sure the folders you point to in your android-sdk path, www path, and your path for application to compile do NOT have spaces in their names
    • Example: (I'm using my E: drive just for preference) E:/Eclipse Workspaces/Mobile/Android will not work. The compiler will try to look for the directory "E:/Eclipse". Create something like "E:/mobile/android/phonegap/
  • For windows users: either use cygwin or git bash to execute above commands. If these options aren't available then try changing the droidgap script and change all calls to the command 'ant' to 'ant.bat', and same thing for the android command calls ('android' to 'android.bat')

 

 

8b. Building Example PhoneGap Android Project

 

Here is an example of creating the example phonegap android app:

 

> git clone http://github.com/phonegap/phonegap-android.git

> cd phonegap-android

> ruby ./droidgap andriod/android-sdk-mac_86/ test_app com.mayerdan.testapp example/ ~/projects/test_droid_phonegap

 

Note if you get errors like:

BUILD FAILED

~/projects/phonegap-android/framework/build.xml:49: taskdef class com.android.ant.SetupTask cannot be found

 

followed by more errors like: 

0:in `stat': No such file or directory - ~/projects/phonegap-android/framework/phonegap.jar

 

To fix this, just run the command with the full path to the android SDK

"sdk.dir=/andriod/android-sdk-mac_86" => "sdk.dir=/projects/andriod/android-sdk-mac_86"

 

Then run `ruby ./droidgap /Users/danmayer/projects/andriod/android-sdk-mac_86 test_app com.mayerdan.testapp example/ ~/projects/test_droid_phonegap` again.

 

9. Creating your first project

Now time to create your project. In Eclipse, go to File > New project > Android > Android Project

 

Now select create project from existing source and navigate to the new folder that was generated in the last step. Select a build target and press finish.

 

*NOTE: The folder you specified in the Ruby script will actually be the folder that your Eclipse will save to, and compile from and NOT your current Eclipse Workspace. Saving your folder to a location inside of a Workspace will not allow you to create the project because the .metadata folder. If you have pointed your folder to one of your Eclipse Workspaces, simply cut and paste the folder to a location that is outside of any Workspace.

 

  

 

 

12) Now, in Eclipse you should see your project

 

 

13) Rightclick phonegap.jar under the libs folder and go to Buildpath -> Add to build path.

 

14) Click the Run button in Eclipse, it is the button that looks like "Play". When you run this project, you should the dialog box to Run As.., choose Android Application. You may get the unable to launch dialog, this can happen if you have the Android 1.5 highlighted when you try to run the project. Just select the project folder and click run.

 

If you have done everything correctly, there should be an Application that loads.  It should be noted that testing with an actual device is preferable to the Emulator for many reasons, namely the fact that it's easier to test the Accelerometer, Geolocation, Beep and Vibrate Functionality.  However, for testing on the actual browser browser events, and various issues with Webkit on Android the Emulator does just as well.

 

 

Notes

 

  • Perhaps JAVA_HOME does not point to the JDK. Or maybe JAVA_HOME doesn't exist. To fix this you must right click on my computer, go to advanced system settings, click the advanced tab, press the environment variables button, Under system variables click new and add JAVA_HOME if it doesn't exist and make the path to the JDK that was installed earlier.

  • ERROR: 

          droidgap:48:in ``': No such file or directory
          android create project -t 7 -k be.progone.test -a PG1 -n PG1 -p E:/baud/work/Mobile/Pr_Eclipse/PG1/build (Errno::ENOENT) 
          from droidgap:48:in `create_android'

 

          SOLUTION:

          Add the Android SDK tools path to the system. Follow steps above to get to system environment variables.

          Eg: C:\Program Files\Android SDK\tools

 

  • ERROR: 
    "BUILD FAILED
    C:\phonegap-android\framework\build.xml:49: taskdef class com.android.ant.SetupTask cannot be found"

    SOLUTION:
    Try going to the "framework" folder and check the path in the local.properties file. See if its correct and pointing to your android sdk directory.

          You MUST use a forward slash in the directory (Windows users) otherwise the paths will not match up.

          Eg: C:/Program Files (x86)/Android SDK

 

 

 

  • ERROR: 

 

      "Click on various buttons on the example app, doesn't do anything" or some things are working but I can't tell what is going on, or I want more information how do I view the Android logs?

 
     SOLUTION:
     To get more information about what is going one while phonegap is running, run the Android log viewer. `adb logcat` if adb isn't found you just need to do the full path to it something like `~/projects/andriod/android-sdk-mac_86/tools/adb logcat`. If you have both a device and a Android emulator running use -d and -e like so `adb -e logcat`. This should give you more info about what is going on. Here is a small example clipping form the android logs.

 

 

D/PhoneGapLog(  291): file:///android_asset/www/phonegap.js: Line 216 : TypeError: Result of expression 'accel' [undefined] is not an object.

E/Web Console(  291): TypeError: Result of expression 'accel' [undefined] is not an object. at file:///android_asset/www/phonegap.js:216

D/dalvikvm(  117): GC_EXPLICIT freed 1727 objects / 91840 bytes in 110ms

D/PhoneGap(  291): The provider network is disabled

D/SntpClient(   61): request time failed: java.net.SocketException: Address family not supported by protocol

 

    From this we can see that the accel is not working. And some information about the location of the Error. This helps debug problems and also helps you to give more information when asking the PhoneGap community for help.  

Comments (Show all 109)

profile picture

Richard Kubina said

at 11:58 am on Jul 14, 2010

I would like to point out that when adding path variables, do NOT put a space after each semi-colon, it matters! Took me hours to figure out why `ant jar` in the ruby script failed. If you see an error with that, try to type 'ant' in a cmd or terminal. If that fails, you gotta make sure your path variables are good to go, no spaces after the semicolons.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Now that I am past that, I have another problem, when I build I see:
Build JAR...

BUILD FAILED:
F:\Development\Android\android-sdk-windows\platforms\android-8\ant\ant_rules_r2.xml:255: Compile failed; see the compiler error output for details.

the xml looks like:

<javac encoding="ascii" target="1.5" debug="true" extdirs=""
destdir="${out.classes.absolute.dir}"
bootclasspathref="android.target.classpath"
verbose="${verbose}" classpath="${extensible.classpath}"
classpathref="android.libraries.jars">
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<src refid="android.libraries.src" />
<classpath>
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
<fileset dir="${extensible.libs.classpath}" includes="*.jar" />
</classpath>
</javac>

with line 255 being: <src refid="android.libraries.src" />

Hmm.. I did see that the target is "1.5", what is that? I am trying to Android 2.2, does that mean anything?

profile picture

Scott said

at 12:04 pm on Jul 14, 2010

@Wuff

Can't say that I've seen that error. Does anyone else have this issue?



@Richard

Having spaces in the ruby script worked just fine for me. As for your error, I have not encountered that.

profile picture

Wuff said

at 7:06 pm on Jul 14, 2010

@Scott - I eventually got it working by editing the "droidgap" script in a text editor... line 47, I set "target_id = 1" instead of 8, and retried, that seemed to do the trick. I'm curious to know why the droidgap script had the target_id set to 8, though - did I miss some step(s) when getting the Android SDK(s)?

profile picture

JITENDRA said

at 12:36 am on Jul 16, 2010

@ Wuff and Scott:-

I am getting the following Error :-

Building the JAR...
Creating Android project for target level 8
Adding www folder to project...
D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1259:in `copy': unknown file type: www/. (RuntimeError)
from D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:459:in `block in copy_entry'
from D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1325:in `preorder_traverse'
from D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:456:in `copy_entry'
from D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:431:in `block in cp_r'
from D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1396:in `block in fu_each_src_dest'
from D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1410:in `fu_each_src_dest0'
from D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1394:in `fu_each_src_dest'
from D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:430:in `cp_r'
from ./droidgap:56:in `include_www'
from ./droidgap:18:in `run'
from ./droidgap:157:in `<main>'

When I run "android list targets", I see:
Available Android targets:
id: 1 or "android-2"
Name: Android 1.1
Type: Platform
API level: 2
Revision: 1
Skins: HVGA (default), HVGA-L, QVGA-L,QVGA-P

I changed the line 47 in Droidgap script from target_id =8 to target_id = 1.

But I am still getting the same error as above.


Further, I am typing this command on the command prompt :-


D:\phonegap-phonegap-android-0.9.1-28-g7304741\phonegap-phonegap-android-7304741
>ruby .\droidgap "d:/android-sdk-windows" Jitendra com.jitendra.demo "d:/phonega
p-phonegap/android-0.9.1-28g7304741/phonegap-phonegap-android-7304741/example" "d:/answer"


I don't know what I am missing out here.


Please help me out to get rid of the above error.

Waiting for a favorable reply.

Thanks in advance,

Regards,

Jitendra

profile picture

Wuff said

at 8:29 am on Jul 17, 2010

@Jitendra - well, I think changing the "target_id = 1" is the correct value for you, based on the output of "android list targets". The error seems to be with the "www" parameter of your call to "ruby .\droidgap". Try making a d:/project/www folder and using that (full) path as the parameter; maybe there's something weird about the long path you're using(?). Unfortunately I'm new to this as well, it took a few tries before I figured out the parameters to use for my app. But I hope that helps...

profile picture

JITENDRA said

at 9:02 pm on Jul 16, 2010

@Wuff and Scott :-

I did changed the target_id to 1 to 10 , but my problem did not solved.

I changes the final directory in the Ruby command to " E:/Android/answer" but still I am getting the same error.

Please help me out . I am stuck badly due to this error.

profile picture

Richard Kubina said

at 1:12 am on Jul 17, 2010

Scott, it wasn't the spaces in the ruby script, it was the spaces in the PATH. The `ant jar` is ruby running a shell command which in turn expects to know what ant means. However, if you space out your variables in your PATH then it won't know what ant is, at least on Windows Server 2003.

I am going to restart all the steps now and see how it goes, I think my target is screwed up as well.

profile picture

Scott said

at 6:08 am on Jul 17, 2010

@Jitendra

I'm new to phonegap as well and I'm not sure why you're getting those errors. Do you need to change the target level for android in the droidgap file?

profile picture

JITENDRA said

at 8:55 pm on Jul 18, 2010

@Wuff and Scott :-

Thanks a lot for your reply.

I got rid of one of the above errors by changing the ruby version from ruby 191 to ruby 186 as well as by changing phonegap to older version.

But now I get other errors too :-


Building the JAR...
Creating Android project for target level 8
Adding www folder to project...
Generating Manifest...
Copying over libraries and assets and creating phonegap.js...
D:/Ruby186/lib/ruby/1.8/fileutils.rb:1200:in `stat': No such file or directory --
D:/phonegap-phonegap-android/framework/phonegap.jar (Errno::ENOENT)
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1200 :in 'lstat'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1178 :in 'stat'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1260 :in 'copy_file'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:463 :in `copy_file''
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:383 :in `cp'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1409:in `fu_each_src_dest0'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:382:in `cp'
from ./droidgap:82:in `copy_libs''
from ./droidgap:20:in `run'
from ./droidgap:157:in `<main>'


Any idea why this error is still coming ?

Any help will be appreciated !

--Jitendra

profile picture

JITENDRA said

at 9:02 pm on Jul 18, 2010


@Wuff and Scott :-

Thanks a lot for your reply.

I got rid of one of the above errors by changing the ruby version from ruby 191 to ruby 186 as well as by changing phonegap to older version.


The Above error was :- D:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1259:in `copy': unknown file type: www/. (RuntimeError)

But now I get other errors too :-


Building the JAR...
Creating Android project for target level 8
Adding www folder to project...
Generating Manifest...
Copying over libraries and assets and creating phonegap.js...
D:/Ruby186/lib/ruby/1.8/fileutils.rb:1200:in `stat': No such file or directory --
D:/phonegap-phonegap-android/framework/phonegap.jar (Errno::ENOENT)
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1200 :in 'lstat'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1178 :in 'stat'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1260 :in 'copy_file'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:463 :in `copy_file''
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:383 :in `cp'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1409:in `fu_each_src_dest0'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
from D:/Ruby186/lib/ruby/1.8/fileutils.rb:382:in `cp'
from ./droidgap:82:in `copy_libs''
from ./droidgap:20:in `run'
from ./droidgap:157:in `<main>'


Any idea why this error is still coming ?

Any help will be appreciated !

--Jitendra

profile picture

JITENDRA said

at 9:38 pm on Jul 19, 2010

I got all my problems resolved.

There was a PATH Problem.

ANT_HOME =D:\apache-ant-1.8.1-bin\apache-ant-1.8.1
JAVA_HOME= C:\Program Files\Java\jdk1.6.0_01
CLASSPATH =C:\Program Files\Java\jdk1.6.0_01\lib;
PATH = D:\apache-ant-1.8.1-bin\apache-ant-1.8.1\bin;C:\Program Files\Java\jdk1.6.0_01\bin;


I got a doubt when I tried 'ant jar' command at D:\android-sdk-windows\tools> it did not generated any jar file , it meant there was something wrong with the PATH for Ant tool , etc


Thanks a lot guys.

profile picture

JITENDRA said

at 9:40 pm on Jul 19, 2010

Now , I need to develop a HELLOWORLD application using "phonegap.js" ,HTML ,javascript.

Anyone any idea how to go around about it !
Any help will be appreciated !

Thanks in advance !

profile picture

JITENDRA said

at 4:40 am on Jul 20, 2010

Just Edit the index.html of the above /assets/www folder now just by removing the code that is not needed and I got it working.

profile picture

Sim Ismail said

at 11:01 pm on Jul 20, 2010

Ok, I got the uuid=undefined fixed with the new release but I still seem far from getting lng/lat from 'Get Location' feature of example app. I'm using IntelliJ on windows and when I press 'Get Location' I receive no console or logcat output.

any1 with experience?

profile picture

JITENDRA said

at 10:06 pm on Jul 21, 2010

I have a simple calculator application in HTML the code is mentioned in the below post, but it does not function in the Android or Symbian Emulator.

The key buttons pressed does not display or type the button what I pressed into the UI of the Calculator using Mouse.

Does anybody had some experience that keyevents does not work in Android,etc... ?

My UI has one Horizontal rectangle Bar where we can display the digits presses and 10 buttons for numbers 0-9 , and +,-,*,/ buttons but when I clcik those numbers , they are not displayed on to the Bar.

Any suggestions will be welcome.

profile picture

JITENDRA said

at 10:18 pm on Jul 21, 2010

<html xmlns=";http://www.w3.org/1999/xhtml">
<head>
<title>Jitendra's Calculator</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script language="javascript" type="text/javascript" src="phonegap.js"></script>
</head>
<body>
<h1>CALCULATOR </h1>
<form name= "Keypad" action ="">
<table border="2" cellpadding="1" bordercolor="black" bgcolor="white" cellspacing="1" width="100">
<tr>
<td>
<input type="text" size="30" length="15" value="" name="ReadOut" style="background:white;color:black;">
</td>
</tr>
</table>
<br/>
<table border="2" cellpadding="2" bordercolor="black" cellspacing="2" width="150" bgcolor="white">
<tr>
<td align="right">
<input name="btnOne" type="Button" value="1" onclick="NumPressed(1)">
</td>
<td align="center">
<input type="button" value=" 2 " name="two" onclick="NumPressed(2)">
</td>
<td align="center">
<input type="button" value=" 3 " name="three" onClick="NumPressed(3)">
</td>
<td align="center">
<input type="button" value=" +" name="add" onclick="Operation('+')">
</td>
<td align="center">
<input type="button" value="ON" name="ON" onclick="On()">
</td>
</tr>
<tr>
<td align="center">
<input type="button" value=" 4 " name="four" onclick="NumPressed(4)">
</td>
<td align="center">
<input type="button" value=" 5 " name="five" onClick="NumPressed(5)">
</td>
<td align="center">
<input type="button" value=" 6 " name="six" onclick="NumPressed(6)">
</td>
<td align="center">
<input type="button" value=" - " name="minus" onclick="Operation('-')">
</td>
<td align="center">
<input type="button" value="OFF" name="OFF" onclick="Off()">
</td>

profile picture

JITENDRA said

at 10:19 pm on Jul 21, 2010

</tr>
<td align="center">
<input type="button" value=" 7 " name="seven" onclick="NumPressed(7)">
</td>
<td align="center">
<input type="button" value=" 8 " name="eight" onclick="NumPressed(8)">
</td>
<td align="center">
<input type="button" value=" 9 " name="nine" onclick="NumPressed(9)">
</td>
<td align="center">
<input type="button" value=" * " name="multiply" onclick="Operation('*')">
</td>
<td align="center">
<input type="button" value="C" name="clear" onclick="Clear()">
</td>
</tr>
<tr>
<td align="center">
<input type="button" value=" . " name="decimal" onclick="Decimal()">
</td>
<td align="center">
<input type="button" value=" 0 " name="zero" onclick="NumPressed(0)">
</td>
<td align="center">
<input type="button" value=" = " name="equal" onclick="Operation('=')">
</td>
<td align="center">
<input type="button" value=" / " name="divide" onclick="Operation('/')">
</td>
<td align="center">
<input type="button" value="+/-" name="sign change" onclick="Neg()">
</td>
</tr>
</table>
</form>
<script language="JavaScript">
<!-- Begin
var FKeyPad = document.Keypad;
var Answer = 0;
var FlagNewNum = false;
var PendingOp = "";
function NumPressed (Num)
{
if (FlagNewNum)
{
FKeyPad.ReadOut.value = Num;
FlagNewNum = false;
}
else
{
if (FKeyPad.ReadOut.value == "0")
FKeyPad.ReadOut.value = Num;
else
FKeyPad.ReadOut.value += Num;
}
}
function Operation (Op) {
var Readout = FKeyPad.ReadOut.value;
if (FlagNewNum && PendingOp != "=");
else
{

profile picture

JITENDRA said

at 10:19 pm on Jul 21, 2010

FlagNewNum = true;
if (PendingOp == '+')
Answer += parseFloat(Readout);
else if ( PendingOp == '-')
Answer -= parseFloat(Readout);
else if ( PendingOp == '/' )
Answer /= parseFloat(Readout);
else if ( PendingOp == '*' )
Answer *= parseFloat(Readout);
else
Answer = parseFloat(Readout);
FKeyPad.ReadOut.value = Answer;
PendingOp = Op;
}
}
function Decimal () {
var curReadOut = FKeyPad.ReadOut.value;
if (FlagNewNum) {
curReadOut = "0.";
FlagNewNum = false;
}
else
{
if (curReadOut.indexOf(".") == -1)
curReadOut += ".";
}
FKeyPad.ReadOut.value = curReadOut;
}
function Clear () {
Answer = 0;
PendingOp = "";
FKeyPad.ReadOut.value = parseInt(FKeyPad.ReadOut.value /10);
FlagNewNum = true;
}
function Neg () {
FKeyPad.ReadOut.value = parseFloat(FKeyPad.ReadOut.value) * -1;
}
function Off () {
FKeyPad.ReadOut.value = "";
Answer = 0;
}
function On () {
FKeyPad.ReadOut.value ="0";
Answer = 0;
}
//--End
</script>

</body>
</html>

profile picture

Wayferer said

at 10:39 pm on Jul 21, 2010

Jitendra, I am having the same problems as you so please keep updating as I'm just getting started and need help too :) Thanks!

profile picture

JITENDRA said

at 10:54 pm on Jul 21, 2010

Hi, the Calculator application now started working on Android 1.5 AVD but not on android 2.0.1 neither on Symbian Emulator, the key presses does not type any numbers on the UI screen on the remaining two Emulators. Its kind of weird.

For Symbian emulator , I am including my index.html and phonegap.js file and following the same steps like zipping www folder of phonegap symbian that includes info.plist,Icon.png ,index.html,phonegap.js of android then changing the extension of this .zip file to .wgz and then opening and installing this application in the symbian emulator then opening this application to use.

profile picture

Wayferer said

at 11:07 pm on Jul 21, 2010

Hi Jitendra, thank you for posting back constantly! I am having issues compiling the example. I was trying with Ruby 191 and it kept failing on the 'ant jar'. I have now switched to using Ruby 186 and, even though it is getting further I am still getting errors. I am now going to try updating my Java install. Any thoughts? What setup are you on now?

profile picture

Wayferer said

at 12:06 am on Jul 22, 2010

I solved my build problem. Am on Win XP, using Ruby 186, PhoneGap 0.9.1. I changed the target_id = 5 to target_id = 1 (for me it can be either 1, 2 or 3). I got this by running android.bat list targets in cmd.

profile picture

Wayferer said

at 12:35 am on Jul 22, 2010

Ok so it appears that you have to use Ruby 191. Otherwise when you build you don't get phonegap.jar showing up in the libs folder. However for some reason the phonegap.jar that I am getting is 'empty', as in no file size...

profile picture

Wayferer said

at 2:09 am on Jul 22, 2010

ok I can't seem to get past this, any help would be appreciated:

C:\Android\phonegap-0.9.1\phonegap-android>ruby .\droidgap "C:/Android/android-sdk_r04-windows/android-sdk-windows" example com.wayferer.example "C:/Android/exa
mple" "C:/Android/exampleBuilt"
Building the JAR...

BUILD FAILED
C:\Android\phonegap-0.9.1\phonegap-android\framework\build.xml:65: Unable to resolve target 'android-8'

Total time: 1 second
Creating Android project for target level 1
Adding www folder to project...
Generating manifest...
Copying over libraries and assets and creating phonegap.js...
C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1265:in `initialize': No such file or directory - C:/Android/phonegap-0.9.1/phonegap-android/framework/phonegap.jar (Errn
o::ENOENT)
from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1265:in `copy_stream'
from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1265:in `block in copy_file'

from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1264:in `open'
from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1264:in `copy_file'
from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:471:in `copy_file'
from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:392:in `block in cp'
from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1396:in `block in fu_each_src_dest'
from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1410:in `fu_each_src_dest0'
from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:1394:in `fu_each_src_dest'
from C:/Ruby191/lib/ruby/1.9.1/fileutils.rb:391:in `cp'
from ./droidgap:82:in `copy_libs'
from ./droidgap:20:in `run'
from ./droidgap:157:in `<main>'

Thanks.

profile picture

JITENDRA said

at 4:19 am on Jul 22, 2010

It works on everything now.!

profile picture

Wayferer said

at 6:42 pm on Jul 22, 2010

What is your environment? i.e. what version of OS / Ruby / PhoneGap?

profile picture

JITENDRA said

at 8:59 pm on Jul 22, 2010

I am using Phonegap 0.9.0 and Ruby 186 .

profile picture

Eshan said

at 2:48 am on Jul 29, 2010

Help me!!
I'm new to phonegap n trying hard to setup in Windows 7. I have phonegap, ruby191, ant and android sdk setup according to the guide mentioned above.
when i execute the follwing code from the phonegap folder using cygdrive :
ruby ./droidgap "c:/android-sdk-windows" appname packagename "wwwpath(for the html,js,css)" "outputpath"

iget: bash:ruby:command not found.

very frustrated....NEWBIE here....HELP NEEDED & Appreciated!

profile picture

Sim Ismail said

at 3:09 am on Jul 29, 2010

Got the Geo Location working for Android on windows IntelliJ after 2 months of hectic efforts and forum scanning...Phew!

profile picture

Sim Ismail said

at 3:10 am on Jul 29, 2010

@Eshan go back to ruby 1.8.7 and then try.

profile picture

Sim Ismail said

at 3:12 am on Jul 29, 2010

@Wayferrer the ant jar issue is updated on the wiki. U need to update the droidgap script and replace with ant.bat jar and android.bat $%$%...

profile picture

Eshan said

at 3:12 am on Jul 29, 2010

correction*

ruby .\droidgap "c:/android-sdk-windows" eshan com.eshan.test "c:/phonegap-phonegap-android-5b5c259/example" "c:/output"

to be precise.....

profile picture

Eshan said

at 3:13 am on Jul 29, 2010

@Sim: K ...at it!

profile picture

Eshan said

at 3:24 am on Jul 29, 2010

Still say ing ruby: command not found after downgrade to ruby 1.8.7
the path variables also got set durind setup...:(

@Sim: thanks for the reply

profile picture

Scott said

at 3:54 am on Jul 29, 2010

Try using backslashes "\" and not forwardslashes "/"

profile picture

JITENDRA said

at 4:08 am on Jul 29, 2010

@Ehsan :- Have you included the Ruby path in the Path Variable of the Environment Variables.

Check if you have set all of these as well as Ruby path in the "Path" variable

ANT_HOME =D:\apache-ant-1.8.1-bin\apache-ant-1.8.1
JAVA_HOME= C:\Program Files\Java\jdk1.6.0_01
CLASSPATH =C:\Program Files\Java\jdk1.6.0_01\lib;
PATH = D:\apache-ant-1.8.1-bin\apache-ant-1.8.1\bin;C:\Program Files\Java\jdk1.6.0_01\bin;


Thanks !

profile picture

Eshan said

at 4:21 am on Jul 29, 2010

@scott n jitendra...thanks!
@scott: i tried the "\" and not "/" forward slash....did not work!

@jitendra: have a look at my path variables:

PATH: C:\Ruby187\bin;C:\android-sdk-windows;C:\android-sdk-windows\tools;C:\ANT_HOME;C:\Program Files\Java\jdk1.6.0;C:\ANT_HOME\bin;C:\Program Files\Java\jdk1.6.0\lib;
ANT_HOME: C:\ANT_HOME
CLASSPATH: C:\Program Files\Java\jdk1.6.0\lib;C:\Program Files\Java\1jre6\lib\ext\QTJava.zip
JAVA_HOME: C:\Program Files\Java\jdk1.6.0

i set these by following the many guides n forums that i visited...kindly suggest changes....i set them from the environment variables button in system settings

profile picture

JITENDRA said

at 10:09 pm on Jul 29, 2010


ANT_HOME =D:\apache-ant-1.8.1-bin\apache-ant-1.8.1 is missing in your path for ANT_HOME.
Can you just try following my style of putting the Path and all.

I am also a beginner.

profile picture

Scott said

at 5:15 am on Jul 29, 2010

@The Developers of PhoneGap (If you even follow up on these comments)

You REALLY need to find a better way of compiling PhoneGap for the mobile platforms. This is RIDICULOUS! So many people are having so many different problems and there are so many hoops to jump through in order just to compile. You guys have a great concept with PhoneGap, but you have horrific execution. I'm no longer going to be using PhoneGap until I see more easier, user friendly means of compiling PhoneGap. Perhaps an IDE should be developed or take advantage of existing technologies (such as Eclipse)

I hope, but am doubtful, that I will get a response from a developer saying that such means are already being developed or are close to development.

profile picture

Eshan said

at 8:15 am on Jul 29, 2010

common guyz....don bail on me now...help me pls...!

You don't have permission to comment on this page.