Невозможно использовать сервис с Cordova / Phonegap helloworld

Я установил Android SDK + Ant + cordova (3.4.1) + установить переменные PATH ( cordova команды android , ant , cordova )

В конце CLI кордовы есть пример использования:

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

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

Поэтому я попробовал именно такой пример:

 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 

На первый взгляд это работает нормально. Я могу открыть http://localhost:8000 и он отображает что-то:

 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 

Я могу щелкнуть ссылку на Android, проблема в том, когда я это делаю, появляется странное диалоговое окно с вопросом = [] , прося меня подтвердить или отменить следующий текст, предварительно заполненный текстом:

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

После принятия я вижу фон Cordova, connecting to device но ничего не происходит, кроме того, что выглядит как бесконечный цикл, который я вижу на консоли:

 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: 

Число 698173 растет

Может ли кто-нибудь сказать мне, что это за странное поведение?

Solutions Collecting From Web of "Невозможно использовать сервис с Cordova / Phonegap helloworld"

Я знаю, что это старый поток, но сегодня у меня была такая же проблема, и я действительно не хочу устанавливать эмулятор

Вам нужно добавить браузер к вашему приложению

 cordova platform add browser 

И укажите ваш браузер на http://localhost:8000/browser/www/

Когда вы изначально запрашиваете диалоговые окна javascript (например, gap: ["PluginManager", …]), вы можете нажать «Отмена», чтобы приложение загрузилось правильно.

После обсуждения IRC с разработчиком Cordova команда serve каким-то образом не документирована, и в основном полезно обслуживать контент в мобильном приложении для мобильных приложений для мобильных телефонов, которое было выпущено недавно, и насколько я понимаю сейчас, теперь он намерен Для обслуживания приложения для обычного браузера рабочего стола.

Для тестирования настольных браузеров я до сих пор был успешным с эмулятором Ripple (а не с плагином Chrome, который кажется непознанным, но пакетом NPM).

Например, вы можете протестировать в приложениях phonegap браузера:

 npm install -g ripple-emulator ripple emulate 

Это может помочь вам: https://github.com/stample/gulp-browserify-react-phonegap-starter