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
Related
I need two permissions:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
So far, what I did: I modified platforms\android\AndroidManifest.xml file manually (in Ionic project) and added this two lines, but this file and whole platforms folder are not under source control. As a result, with each clean checkout, these permissions are missing.
Is there a way to specify these two permissions somewhere in Ionic configuration that is in git?
You can use following lines in config.xml
<feature name="Camera">
<param name="android-package" value="org.apache.cordova.CameraLauncher" />
</feature>
Can Refer below link
https://cordova.apache.org/docs/en/3.0.0/cordova/camera/camera.html
I am writing a Cordova plugin for Android, and it is not registering a JavaScript object to window and I would like to know why.
In the plugin's plugin.xml, I am using <js-module> to register the js object to window object:
<platform name="android">
<js-module src="www/Loading.js" name="loader">
<clobbers target="loader" />
</js-module>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Loading">
<param name="android-package" value="org.apache.cordova.loader.Loading" />
<param name="onload" value="true" />
</feature>
</config-file>
...
</platform>
The plugin compiles, but when I do window.loader in Chrome debugger, it is undefined. I tried changing the value of target in <clobbers> to window.loader to no avail.
www/Loading.js file is exporting a JavaScript object using module.exports:
function Loading() {
...
}
module.exports = new Loading();
Any suggestions?
Resolved. This is a very specific case for my app. I am copying everything from the sandboxed environment to an internal path and booting the app from the internal path. Turns out the app was not copying the www/Loader.js file.
I have a phongap app almost ready to be released,
The app gets data from a database (AJAX), shows the users location on google maps and stores a few strings in the users localstorage.
I built my app useing phonegap build and it all works great.
My problem is when I download the APK to my device I am asked for all posible permissions.
I unchecked all unwanted features in the WMAppManifest, and my config.xml shows:
<features>
<feature name="Device">
<param name="wp-package" value="Device" onload="false"/>
<param name="android-package" value="Device" />
</feature>
<feature name="NetworkStatus">
<param name="wp-package" value="NetworkStatus"/>
<param name="android-package" value="NetworkStatus" /></feature>
I'm pretty sure my problem is in the config file but what is it?
Thanks in advance.
You can set the individual permissions in your apps config.xml.
First, disable all permissions.
<preference name="permissions" value="none" />
After that, you can enable the required permissions one by one.
<feature name="http://api.phonegap.com/1.0/network" />
<feature name="http://api.phonegap.com/1.0/camera" />
<feature name="http://api.phonegap.com/1.0/notification" />
<feature name="http://api.phonegap.com/1.0/geolocation" />
<feature name="http://api.phonegap.com/1.0/media" />
<feature name="http://api.phonegap.com/1.0/contacts" />
<feature name="http://api.phonegap.com/1.0/file" />
<feature name="http://api.phonegap.com/1.0/battery" />
<feature name="http://api.phonegap.com/1.0/device" />
Just insert the feature(s) you need – the others can/should be left out.
Source: PhoneGap Build Documentation (Features section)
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
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