I developed a cordova app which uses the contacts plugin. I tested it on android with my linux machine and everything works fine. Now I am trying to use phonegap build to create an ios package. My problem is with the contacts plugin, the code for getting contacts doesn't work when I use it in IOS. I tried adding this line to my config.xml:
<gap:plugin name="org.apache.cordova.contacts" version="0.2.11" />
But it didn't help.
The UI also looks different (everything is smaller). This is not an IOS compatibility issue - I tried the apk created by phonegap build for android on the same android phone I used for development and the UI has the same problems it had on IOS. What am I doing wrong?
Thanks.
Try adding this to config.xml
<feature name="Contacts">
<param name="ios-package" value="CDVContacts" />
</feature>
For android you have to use this
<feature name="Contacts">
<param name="android-package" value="org.apache.cordova.ContactManager" />
</feature>
Please refer this for more details
http://docs.phonegap.com/en/3.0.0/cordova_contacts_contacts.md.html
Related
I tried other solutions around here but no matter what I do the same permissions are asked during install of my app.
I tried removing a bunch of the "plugins" phonegap uses, namely: (from the config.xml)
<gap:plugin name="org.apache.cordova.battery-status"/>
<gap:plugin name="org.apache.cordova.camera"/>
<gap:plugin name="org.apache.cordova.media-capture"/>
<gap:plugin name="org.apache.cordova.contacts"/>
<gap:plugin name="org.apache.cordova.geolocation"/>
<gap:plugin name="org.apache.cordova.globalization"/>
Yet when I update my code and then try to install the apps it still asks for stuff like location.
Anyone who knows this?
It isn't the plugins that declare the permissions. The permissions are declared with feature elements like
<feature name="http://api.phonegap.com/1.0/camera"/>
<feature name="http://api.phonegap.com/1.0/device"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/network"/>
I would be glad if we had an example on how cordova plugins should be wrapped for CocoonJS.
I'm trying to use the device-orientation plugin (compass) in a simple example but after the app has initialized, the navigator.compass.getCurrentHeading() returns an CompassError with the code:
Class not found
The class name cannot be resolved correctly, so probably something's wrong with the config.xml file.
After combining many sources, mine looks like this:
../www/config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="my.compass.html" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordovaCompass</name>
<description>
A sample Apache Cordova application that displays the current compass heading after the deviceready event.
</description>
<author email="a#cordova.apache.org" href="http://cordova.io">
</author>
<content src="index.html" />
<access origin="*" />
<preference name="fullscreen" value="true" />
<preference name="orientation" value="landscape" />
<preference name="webviewbounce" value="true" />
<feature name="App">
<param name="android-package" value="org.apache.cordova.App" />
</feature>
<feature name="Compass">
<param name="android-package" value="org.apache.cordova.deviceorientation.CompassListener" />
</feature>
</widget>
I've also tried to include compass as plugin:
<plugin name="Compass" value="org.apache.cordova.device-orientation" />
with no difference..
PS: The app works fine on plain Cordova.
[UPDATE]
Maybe the problem is here:
For this example I zipped the <project-name>/platforms/android/assets/www folder.
I'm not sure if this is enough for a Cordova plugin app, as the native code of the plugin is not included (CompassListener.java) and the only part that seems to work is actually its JavaScript interface (compass.js, CompassError.js, etc)..
On the other hand, If I try to zip the whole <project-name> directory as pointed out at the bottom of this tutorial, the CocoonJS Launcher crashes..
So, could at least someone confirm that the launcher can actually compile Cordova plugins?
If you want to use plugins you have to zip all Cordova project folders. Example:
cd ~/projects/ && zip -r -X hellococoonfull.zip helloCocoonJS && cd -
See the section "Using Cordova Plugins" of Getting Started with Cordova and CocoonJS guide.
[Update]
The CocoonJS Launcher is not ready for plugins yet. For using plugins you have to use de cloud compilation system.
I'm writting an android and iphone app using phonegap 3.0.
So far I have been only compiling the apps remotely using phonegap build.
Now I'm trying to add the geolocation plugin to my app, and in iphone was easy, since I only had to modify the config.xml file.
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
So far so good, the problem was that when adding geolocation to android, the documentation indicates that I have set the following configuration:
(in app/res/xml/config.xml)
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.GeoBroker" />
</feature>
(in app/AndroidManifest.xml)
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
But I don't have an AndroidManifest.xml file. I could generate the complete android app using:
cordoba platform add android
But I'm not sure if this is what I should do.
Is is what I should be doing? or there is a way to add geolocation without generating the entire android project?
I am a bit confused because you say you are using phonegap 3.0 and you also mention phonegap-build (highest is 2.9). If you are in fact using phonegap-build, the only thing you need is in your config.xml:
<feature name="http://api.phonegap.com/1.0/geolocation"/>
I had the same problem. My geolocation worked on IOS but not on Android. So I Added to config.xml
<feature name="http://api.phonegap.com/1.0/geolocation"/>
As explained by Dom.This was not sufficient. I wanted to share what I did step by step because I lost about 18h of dev time looking for the solution.
This however did not reslove the problem. So I added the plugin using my IDE.
This added the following to the config:
<plugin name="cordova-plugin-geolocation" version="2.2.0" />
I then went inside the plugin.xml under the plugin directorty.
And looked if the following was added.
<!-- android -->
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</config-file>
...
It was, so I rebooted the device. (on the Ionic forum they say, it might help)
When reinstalling the app I checked for the permission. And it was added. So for the bad Q of the last pic but I took a pic with my cam for it. Hope this helps
Working on Windows with Phonegap 3.0, Android platform, debugging in Eclipse.
I was able to get my old app to compile but I have encountered a new problem when I try to use a feature that is now a plugin.
I have added all the plugins I need through the CLI tool and have added the "feature" data to the config.xml file, so I assume that they are available to be called. The permissions are also set in the manifest file.
FileTransfer
I see that the File Transfer API example code has not changed for 3.0, so I left the call the same in my code. So the file will download but then I get an error that makes my app crash
"
D/CordovaLog(12883): file:///android_asset/www/phonegap.js: Line 932 : Uncaught Error: Error calling method on NPObject!
"
I did some searching for this error and there doesn't seem to be a standard solution?
Perhaps there is a new way to call features that are within plugins? Because I can't play an audio file without getting errors as well. The sound file will play but will cause errors.
"
09-01 20:13:17.274: W/PluginManager(13279): THREAD WARNING: exec() call to Media.startPlayingAudio blocked the main thread for 23ms. Plugin should use CordovaInterface.getThreadPool().
"
I have re-read the media API and there is no mention of a thread pool. I am doing all of my programming in javascript.
Essentially where ever I use a plugin feature the app has major errors. I tried using my record sound feature in my previously working app, and when I call a stop to my recording it throws an error
"
09-01 20:10:04.206: E/AudioPlayer(13279): FAILED renaming /mnt/sdcard/tmprecording.3gp to /sdsub/myapp/Recorded/myRecording.amr
"
I tested the file transfer api again through my file remove function and it also failed
"
09-01 20:16:00.884: W/PluginManager(13279): THREAD WARNING: exec() call to File.remove blocked the main thread for 19ms. Plugin should use CordovaInterface.getThreadPool().
"
it seems like the essential nature of how features work has changed but is not documented anywhere. The API calls seem unchanged from older versions, just how you install the API features is different, but I followed that guide and installed them.
Is there a new API guide that I have missed? because the Phonegap API documentation hasn't changed for how these features are called in 3.0.
Thanks.
my config file
<feature name="App">
<param name="android-package" value="org.apache.cordova.App" />
</feature>
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
<feature name="File">
<param name="android-package" value="org.apache.cordova.file.FileUtils" />
</feature>
<feature name="FileTransfer">
<param name="android-package" value="org.apache.cordova.filetransfer.FileTransfer" />
</feature>
<feature name="Media">
<param name="android-package" value="org.apache.cordova.media.AudioHandler" />
</feature>
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>
<feature name="Compass">
<param name="android-package" value="org.apache.cordova.deviceorientation.CompassListener" />
</feature>
my Manifest file
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.INTERNET" />
while you are upgrading your application , the phonegap.jsfile must suppport all the functional script . you can use the suitable version of javascript file like phonegap.0.9.5.js or higher version too . It might be because the phonegap.js didn't contain the necessary function needed by the application . If you see the API they have the phonegap .X.Y.Z.js . so you can try higher one
I am Using PhonegapBuild Not eclipse for build my application.
We are not using any custom plugin. I read the post about plugin but i think it's for custom plugin so i didn't change anything in XML and it gives me error "plugin unsupported: splashscreen" So can any one help me how to get rid of it.
In Config.xml splash plugin line is same as mentioned in docs and it's as below
For Android:
<gap:plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
For IOS:
<gap:plugin name="SplashScreen" value="CDVSplashScreen" />
Please help me..
Screenshot is below
I removed all plugin from my config.xml for Android as well IOS also.Then i successfully upload my Zip file for Build and its Build and Working Fine in Device..
As far as I can tell, you must be confused with the feauture and the plugin
Try using the following for the feauture
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.SplashScreen"/>
</feature>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen" />
</feature>
Try using the following for the plugin
<gap:plugin name="cordova-plugin-splashscreen" source="npm" version="2.1.0" />
But I also have a problem with my splashscreen, so it may not be 100% correct. My problem is that my images are not being recognized.