No se puede usar servir con Cordova / Phonegap helloworld

He instalado Android SDK + Ant + cordova (3.4.1) + set variables PATH ( android , ant , cordova comandos están disponibles)

Al final del cordoba CLI, hay este ejemplo de uso:

 Example usage $ cordova create Baz $ cd Baz $ cordova platform add android $ cordova build $ cordova serve android 

———————————–

Así que probé ese ejemplo:

 sebastien@sebastien-xps:Desktop$ cordova create Baz Creating a new cordova project with name "HelloCordova" and id "io.cordova.hellocordova" at location "/home/sebastien/Desktop/Baz" 

 sebastien@sebastien-xps:Desktop$ cd Baz 

 sebastien@sebastien-xps:Baz$ cordova platform add android Creating android project... Creating Cordova project for the Android platform: Path: platforms/android Package: io.cordova.hellocordova Name: HelloCordova Android target: android-19 Copying template files... Running: android update project --subprojects --path "platforms/android" --target android-19 --library "CordovaLib" Resolved location of library project to: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib Updated and renamed default.properties to project.properties Updated local.properties No project name specified, using Activity name 'HelloCordova'. If you wish to change it, edit the first line of build.xml. Added file platforms/android/build.xml Added file platforms/android/proguard-project.txt Updated project.properties Updated local.properties No project name specified, using project folder name 'CordovaLib'. If you wish to change it, edit the first line of build.xml. Added file platforms/android/CordovaLib/build.xml Added file platforms/android/CordovaLib/proguard-project.txt Project successfully created. 

 sebastien@sebastien-xps:Baz$ cordova build Running command: /home/sebastien/Desktop/Baz/platforms/android/cordova/build Buildfile: /home/sebastien/Desktop/Baz/platforms/android/build.xml -set-mode-check: -set-debug-files: -check-env: [checkenv] Android SDK Tools Revision 22.6.2 [checkenv] Installed at /home/sebastien/Desktop/devhome/install/adt-bundle-linux-x86_64-20140321/sdk -setup: [echo] Project Name: HelloCordova [gettype] Project Type: Application -set-debug-mode: -debug-obfuscation-check: -pre-build: -build-setup: [getbuildtools] Using latest Build Tools: 19.0.3 [echo] Resolving Build Target for HelloCordova... [gettarget] Project Target: Android 4.4.2 [gettarget] API level: 19 [echo] ---------- [echo] Creating output directories if needed... [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/ant-build [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/ant-build/res [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/ant-build/rsObj [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/ant-build/rsLibs [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/ant-gen [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/ant-build/classes [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/ant-build/dexedLibs [echo] ---------- [echo] Resolving Dependencies for HelloCordova... [dependency] Library dependencies: [dependency] [dependency] ------------------ [dependency] Ordered libraries: [dependency] [dependency] ------------------ [echo] ---------- [echo] Building Libraries with 'debug'... nodeps: -set-mode-check: -set-debug-files: -check-env: [checkenv] Android SDK Tools Revision 22.6.2 [checkenv] Installed at /home/sebastien/Desktop/devhome/install/adt-bundle-linux-x86_64-20140321/sdk -setup: [echo] Project Name: CordovaLib [gettype] Project Type: Android Library -set-debug-mode: -debug-obfuscation-check: -pre-build: -build-setup: [getbuildtools] Using latest Build Tools: 19.0.3 [echo] Resolving Build Target for CordovaLib... [gettarget] Project Target: Android 4.4.2 [gettarget] API level: 19 [echo] ---------- [echo] Creating output directories if needed... [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/res [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/libs [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/res [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/rsObj [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/rsLibs [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-gen [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/classes [mkdir] Created dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/dexedLibs [echo] ---------- [echo] Resolving Dependencies for CordovaLib... [dependency] Library dependencies: [dependency] No Libraries [dependency] [dependency] ------------------ -code-gen: [mergemanifest] Merging AndroidManifest files into one. [mergemanifest] Manifest merger disabled. Using project manifest only. [echo] Handling aidl files... [aidl] No AIDL files to compile. [echo] ---------- [echo] Handling RenderScript files... [echo] ---------- [echo] Handling Resources... [aapt] Generating resource IDs... [echo] ---------- [echo] Handling BuildConfig class... [buildconfig] Generating BuildConfig class. -pre-compile: -compile: [javac] Compiling 89 source files to /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/classes [javac] Note: Some input files use or override a deprecated API. [javac] Note: Recompile with -Xlint:deprecation for details. [echo] Creating library output jar file... [jar] Building jar: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/classes.jar -post-compile: -obfuscate: -dex: [echo] Library project: do not convert bytecode... -crunch: [crunch] Crunching PNG Files in source dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/res [crunch] To destination dir: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/res [crunch] Crunched 0 PNG files to update cache -package-resources: [echo] Library project: do not package resources... -package: [echo] Library project: do not package apk... -post-package: -do-debug: [echo] Library project: do not create apk... [propertyfile] Creating new property file: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/build.prop [propertyfile] Updating property file: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/build.prop [propertyfile] Updating property file: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/build.prop [propertyfile] Updating property file: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/build.prop -post-build: debug: -code-gen: [mergemanifest] Merging AndroidManifest files into one. [mergemanifest] Manifest merger disabled. Using project manifest only. [echo] Handling aidl files... [aidl] No AIDL files to compile. [echo] ---------- [echo] Handling RenderScript files... [echo] ---------- [echo] Handling Resources... [aapt] Generating resource IDs... [echo] ---------- [echo] Handling BuildConfig class... [buildconfig] Generating BuildConfig class. -pre-compile: [echo] Set jars path to: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/classes.jar -compile: [javac] Compiling 3 source files to /home/sebastien/Desktop/Baz/platforms/android/ant-build/classes -post-compile: -obfuscate: -dex: [dex] input: /home/sebastien/Desktop/Baz/platforms/android/ant-build/classes [dex] input: /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/classes.jar [dex] Pre-Dexing /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build/classes.jar -> classes-f44eaf7d8904b207eb36100ec05db9be.jar [dex] Converting compiled files and external libraries into /home/sebastien/Desktop/Baz/platforms/android/ant-build/classes.dex... [dx] Merged dex A (7 defs/2.2KiB) with dex B (205 defs/312.8KiB). Result is 212 defs/383.8KiB. Took 0.3s -crunch: [crunch] Crunching PNG Files in source dir: /home/sebastien/Desktop/Baz/platforms/android/res [crunch] To destination dir: /home/sebastien/Desktop/Baz/platforms/android/ant-build/res [crunch] Processing image to cache: /home/sebastien/Desktop/Baz/platforms/android/res/drawable-hdpi/icon.png => /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable-hdpi/icon.png [crunch] (processed image to cache entry /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable-hdpi/icon.png: 67% size of source) [crunch] Processing image to cache: /home/sebastien/Desktop/Baz/platforms/android/res/drawable-ldpi/icon.png => /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable-ldpi/icon.png [crunch] (processed image to cache entry /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable-ldpi/icon.png: 0% size of source) [crunch] Processing image to cache: /home/sebastien/Desktop/Baz/platforms/android/res/drawable-mdpi/icon.png => /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable-mdpi/icon.png [crunch] (processed image to cache entry /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable-mdpi/icon.png: 0% size of source) [crunch] Processing image to cache: /home/sebastien/Desktop/Baz/platforms/android/res/drawable-xhdpi/icon.png => /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable-xhdpi/icon.png [crunch] (processed image to cache entry /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable-xhdpi/icon.png: 53% size of source) [crunch] Processing image to cache: /home/sebastien/Desktop/Baz/platforms/android/res/drawable/icon.png => /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable/icon.png [crunch] (processed image to cache entry /home/sebastien/Desktop/Baz/platforms/android/ant-build/res/drawable/icon.png: 53% size of source) [crunch] Crunched 5 PNG files to update cache -package-resources: [aapt] Creating full resource package... -package: [apkbuilder] Current build type is different than previous build: forced apkbuilder run. [apkbuilder] Creating HelloCordova-debug-unaligned.apk and signing it with a debug key... -post-package: -do-debug: [zipalign] Running zip align on final apk... [echo] Debug Package: /home/sebastien/Desktop/Baz/platforms/android/ant-build/HelloCordova-debug.apk [propertyfile] Creating new property file: /home/sebastien/Desktop/Baz/platforms/android/ant-build/build.prop [propertyfile] Updating property file: /home/sebastien/Desktop/Baz/platforms/android/ant-build/build.prop [propertyfile] Updating property file: /home/sebastien/Desktop/Baz/platforms/android/ant-build/build.prop [propertyfile] Updating property file: /home/sebastien/Desktop/Baz/platforms/android/ant-build/build.prop -post-build: [move] Moving 1 file to /home/sebastien/Desktop/Baz/platforms/android/ant-build [move] Moving 1 file to /home/sebastien/Desktop/Baz/platforms/android/CordovaLib/ant-build debug: BUILD SUCCESSFUL Total time: 18 seconds 

 sebastien@sebastien-xps:Baz$ cordova serve android Static file server running on port 8000 (ie http://localhost:8000) CTRL + C to shut down 302 /android/ 200 /android/www/ 200 /android/www/css/index.css 200 /android/www/cordova.js 200 /android/www/js/index.js 200 /android/www/img/logo.png 

Esto parece funcionar bien a primera vista. Puedo abrir http://localhost:8000 y muestra algo:

 Package Metadata name HelloCordova packageName io.cordova.hellocordova version 0.0.1 Platforms ios android ubuntu amazon-fireos wp7 wp8 blackberry10 www firefoxos windows8 Plugins 

Puedo hacer clic en el enlace de Android, el problema es cuando lo hago, aparece un extraño cuadro de diálogo con pregunta = [] , pidiéndome que confirme o cancele el texto siguiente texto prellenado:

 gap:["PluginManager","startup","PluginManager1413322690"] 

Después de aceptar, puedo ver el fondo de Cordova, connecting to device pero no pasa nada excepto algo que se parece a un bucle infinito que puedo ver en la consola:

 The key "target-densitydpi" is not supported. localhost/:25 Falling back on PROMPT mode since _cordovaNative is missing. Expected for Android 3.2 and lower only. cordova.js:966 698173 processMessage failed: invalid message: 

El número 698173 está creciendo

¿Puede alguien decirme qué es esta conducta extraña?

3 Solutions collect form web for “No se puede usar servir con Cordova / Phonegap helloworld”

Sé que es un viejo hilo, pero tenía el mismo problema hoy y realmente no quiero instalar un emulador

Necesitas agregar la plataforma del navegador a tu aplicación

 cordova platform add browser 

Y apunte su navegador a http://localhost:8000/browser/www/

Cuando se le solicita inicialmente con los cuadros de diálogo de javascript (por ejemplo, gap: ["PluginManager", …]) puede presionar Cancelar para que la aplicación se cargue correctamente.

Después de las discusiones en el IRC con un desarrollador de Cordova, el comando de servicio es de alguna manera no está bien documentado y es sobre todo útil para servir el contenido a la aplicación móvil Phonegap App Developer que fue lanzado recientemente, y hasta donde yo lo entiendo ahora, Para servir la aplicación para un navegador de escritorio normal.

Para las pruebas de navegador de escritorio, he tenido éxito hasta ahora con el emulador de Ripple (no el complemento de Chrome que parece no mantenido, pero el paquete NPM).

Por ejemplo, puedes probar en las aplicaciones del teléfono móvil del navegador con:

 npm install -g ripple-emulator ripple emulate 

Esto puede ayudarle a: https://github.com/stample/gulp-browserify-react-phonegap-starter

  • Ajustar ajustes de tono en Android mediante Phonegap
  • ¿Cómo implementar onclick en javascript y html para dispositivos con versiones inferiores de android?
  • Cordova Android Error al cargar recurso: net :: ERR_NAME_NOT_RESOLVED
  • Módulo cordova / exec / proxy no encontrado usando Cordova phonegap
  • Error al intentar ejecutar una aplicación Cordova en un dispositivo Android
  • Integración de Adwhirl con Cordova 2.0 en Android
  • ¿Cómo puedo obtener un objeto File de PhoneGap camera.getPicture?
  • Algunos ionicones no mostrando
  • No se puede cordova meteoro aplicación (Error: ENOENT)
  • Se ha producido un error al enumerar los objetivos de Android
  • PhoneGap: un mal rendimiento en comparación con el navegador en Android
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.