tus camisetas frikis en camisetafriki.com
Home > Programacion > Empezando con PhoneGap + Windows

Empezando con PhoneGap + Windows

En la Campus Party 2010 he asistido a una charla de espresso-team relacionada con aplicaciones web para móviles que se ejecutan como si fueran nativas. En este ámbito PhoneGap se lleva la palma y dado que las instrucciones de la web no son todo lo aclaratorias que deberían ser, voy a a indicar algunos consejos que me han ayudado a compilar el .jar con las librerías y a crear el proyecto de prueba:

Pasos:

1. Instalar el Java JDK:
http://java.sun.com/javase/downloads/index.jsp

2. Instalar Eclipse:
http://www.eclipse.org/downloads/ (extraer en algún sitio)

3. Instalar Android SDK:
http://developer.android.com/sdk/index.html (descomprimir en alguna ruta sin espacios, ej e:\android-sdk)
Importante para evitar dolores de cabeza después, añadir a la variable de entorno PATH la ruta hasta la carpeta del SDK (ej e:\android-sdk) y a la carpeta tools (ej. e:\android-sdk\tools)

4. Instalar el plugin ADT para Eclipse:
http://developer.android.com/sdk/eclipse-adt.html

5. Añadir componentes del SDK:
http://developer.android.com/sdk/adding-components.html

Si hay alguna duda hasta aquí, es como seguir la guía de Android para desarrolladores: http://developer.android.com/sdk/index.html

6. Instalar Apache ANT:
http://ant.apache.org/index.html (descomprimir en una carpeta sin espacios ej. e:\apache-ant)
IMPORTANTE: Crear dos variables de entorno, JAVA_HOME con la ruta al java_sdk (ej. C:\Program Files (x86)\Java\jdk1.6.0_20) y ANT_HOME con la ruta a la carpeta de ANT (ej. e:\apache-ant), además, añadir la ruta al /bin de ANT al PATH (ej. e:\apache-ant\bin)

7. Instalar ruby
Con instalador: http://rubyinstaller.org/

8. Instalar PhoneGap:
Hay dos opciones, instalar un cliente de github y bajárselo con él, o descargarte la última versión a mano de http://github.com/phonegap/phonegap-android (descomprimir en una carpeta)

9. Correr el comando mágico que creará tu .jar y el proyecto de ejemplo:
Dentro de la carpeta de phonegap-android:
ruby ./droidgap [ruta al android sdk] [nombre aplicacion] [nombre del package] [ruta al www] [ruta al proyecto de prueba]

dónde:
[ruta al android sdk] = ruta donde has descomprimido el SDK de android
[nombre aplicacion] = el que quieras, será el nombre de la aplicación
[nombre del package] = el que quieras, será el nombre del paquete
[ruta al www] = ruta donde están las fuentes html, que si no tienes, puedes poner la carpeta example de phonegap-android
[ruta al proyecto de prueba] = carpeta donde se creará el proyecto para abrir con Eclipse

En mi caso:
ruby ./droidgap e:\\Android\\android-sdk-windows test com.forgotten example/ e:\\Android\\proyectos\\phonegap1

10. Abrir Eclipse, crear un nuevo proyecto Android e indicar que lo queremos crear a partir de un código fuente existente, que será el que hemos indicado en [ruta al proyecto de prueba]

11. En el árbol de ficheros, clic derecho en libs/phonegap.jar > Build path > Add to build path

12. Clic derecho en la carpeta del proyecto dentro de Ecplise > Run As > Android Aplication.
Debes tener configurado un AVD compatible con el build target indicado en el manifest.xml.
Para más info sobre esto mejor ver el quick start de http://developers.android.com

Posibles errores:
./droidgap:37:in “’: No such file or directory – ant jar (Errno::ENOENT)
Solución, añadir la ruta de ANT a la variable de entorno PATH.

./droidgap:49:in “’: No such file or directory – android create project
Solución, añadir la ruta a las tools de Android SDK a la variable de entorno PATH.

Esto me ha llevado un montón conseguirlo por no leer las cosas, así que espero que sirva de ayuda

Categories: Programacion Tags: ,
  • Anonymous

    Hi there,
    My name is Michael

    I’ve made it my job to help people succeed online.

    I’m constantly on the lookout for the best ways
    and means to make your job simpler, and I pass
    the good stuff on to you.

    I have developed the eBay Cash Machine – it allows
    everyone to make a great income on eBay 99%
    automatically. It only takes a few minutes to set
    up and once that is done you will have your own eBay
    Businesses that literally run on auto-pilot!

    You just wait for the money to come in!

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    We have developed a software that automatically
    places your ad on millions of blogs.

    You will receive thousands of targeted hits to
    your website as Blog Blaster places your ad on
    blogs that match your ad’s category.

    This method has never been released to the public
    before. Very few, if anyone has implemented this.

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    Hi,
    My name is Michael,

    Do you really know what it takes to quickly
    generate high-quality traffic to your Web Site?

    Listen up. I must let you in on a few insider *secrets*:

    Instead of waiting months to generate sales on your
    site, you can start gaining the hits you want right now.

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    More and more people are subscribing to feeds every day and
    there are millions who are already subscribed.

    Your ad will reach a very broad range of potential customers.

    Feed Blaster is the first & only submitter that can submit your
    ads to thousands of feeds within a few minutes!

    Right, that would mean you would have millions of sites
    linking to your ad and millions of users reading your
    message within minutes.

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    No Matter what you are selling – Hit-Booster
    will send targeted visitors to your website!

    Within 15 minutes you will have your own website
    traffic generator that will bring in an ever increasing
    amount of hits to your websites! Automatically

    This software is perfect for bringing real traffic to
    your site… even if… it’s an affiliate link where you
    have no control over the website content!

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    We have developed a software that automatically
    places your ad on millions of blogs.

    You will receive thousands of targeted hits to
    your website as Blog Blaster places your ad on
    blogs that match your ad’s category.

    This method has never been released to the public
    before. Very few, if anyone has implemented this.

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    What if you could drive 1000s of
    customers to your website from the
    major search-engines that are exclusively
    looking for your product/offer for free ?

    What about an instant number one
    ranking for your keywords, for free ?!

    We have developed a program that
    will automatically do this for you.

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    Numerous companies are looking for workers
    to submit information into online forms and
    they will pay you nicely in return.

    This is not a get-rich-quick scheme but
    a legitimate way to earn money from home.

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    No Matter what you are selling – Hit-Booster
    will send targeted visitors to your website!

    Within 15 minutes you will have your own website
    traffic generator that will bring in an ever increasing
    amount of hits to your websites! Automatically

    This software is perfect for bringing real traffic to
    your site… even if… it’s an affiliate link where you
    have no control over the website content!

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    We have developed a software that automatically
    places your ad on millions of blogs.

    You will receive thousands of targeted hits to
    your website as Blog Blaster places your ad on
    blogs that match your ad’s category.

    This method has never been released to the public
    before. Very few, if anyone has implemented this.

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file

  • Anonymous

    Hi there,
    My name is Michael

    I’ve made it my job to help people succeed online.

    I’m constantly on the lookout for the best ways
    and means to make your job simpler, and I pass
    the good stuff on to you.

    I have developed the eBay Cash Machine – it allows
    everyone to make a great income on eBay 99%
    automatically. It only takes a few minutes to set
    up and once that is done you will have your own eBay
    Businesses that literally run on auto-pilot!

    You just wait for the money to come in!

    For Full Details please read the attached .html file

    To Unsubscribe please read the attached Unsubscribe.txt file