I have a problem using the Facebook Connect plugin with PhoneGap.
I have added this line to file plugins.xml:
<plugin name="com.phonegap.facebook.Connect" value="com.phonegap.facebook.ConnectPlugin" />
And this include on in file FbDialog.java:
import com.phonegap.helloworld.R;
I have these files on src:
com
/facebook/android/
AsyncFacebookRunner.java
DialogError.java
Facebook.java
FacebookError.java
FbDialog.java
Util.java
/phonegap/
facebook/ConnectPlugin.java
helloworld/HelloPhoneGapActivity.java
The ressources files close and the icon is copied. In HTML, I include some JavaScript code:
cordova-1.6.1.js
cdv-plugin-fb-connect.js
facebook_js_sdk.js
I use the default HTML example with my appId.
When I run application on my Android phone, a dialog says:
Cordova Facebook connect plugin fail on init!
and
Cordova Facebook connect plugin fail on auth.status!
If I click the login bouton, the dialog says:
Cordova Facebook connect plugin fail on login!Class not found
And the Eclipse console log is:
I tried to install this with the officiel Git readme and the
tutorial Add Facebook login to PhoneGap/Cordova Android app Easiest way.
When I compile the application, I don't get the error.
How do I fix this problem?
After the switch to Cordova, everything got renamed. You need the new class location:
<plugin name="org.apache.cordova.facebook.Connect" value="org.apache.cordova.facebook.ConnectPlugin" />
You'll have to put your plugin java (back?) to the correct location as well in org/apache/cordova/facebook/ .
Unfortunately, the error for this is pretty vague, but you can see it if you know what to look for. You can see in your logs the line with Message=Class not found in it. It would be better if this line had the name of the class. This error happens when you call the JS for a plugin, but then the right class name can't be found in the plugins.xml file. This is also why you notice that any call fails the same way.
Verify that android studio isn't giving an error like:
A valid Facebook app id must be set in the AndroidManifest.xml or set by calling FacebookSdk.setApplicationId before initializing the sdk.
If so, then edit androidmanifest. See: A valid Facebook app id must be set in the AndroidManifest.xml
Related
I am new to all of this, so I am probably missing something pretty obvious, but I am trying to change the userAgent string in an application I am building with Cordova. Based upon the documentation at the Cordova website, it would appear that I should only need to add the following to my config.xml file:
preference name="OverrideUserAgent" value="My string value here"
So I included this line in my config.xml and then added this code to my javascript in my cordova app:
var ua = navigator.userAgent;
alert(ua);
I then build the project and install it on my android phone. However, when I run the app I get the same userAgent reported back by my alert regardless of whether I included preference name="OverrideUserAgent" value="My string value here" in the config.xml or not. I am using version 5 of Cordova (5.3.1 I believe) and this config.xml fix was listed in the documentation for version 5.1.1 on the Cordova website.
I have also seen another possible fix on stackoverflow in the following post:
Change PhoneGap / Cordova User-Agent for AJAX
Specifically I am looking at the response that recommends:
put this in your onCreate method: (after super.init();)
super.appView.getSettings().setUserAgentString("Your own agent string");
I am sorry to ask such a basic question, but how to I carry this out? Is it possible to do this while still using the Cordova CLI or do I need to import the project into Android studio first? Where exactly do I find the onCreate method that I need to modify.
Thank you for any help you may be able to offer.
while trying to create a push Notification using GCM Per device or a group of devices - we are trying to use Onesignal for registration of our android users and getting an undefined error.
the code is written on JS and then build using Phonegap and realesed as an APK for android, while debugging it we get "windwos.onesignal undefined"
any lead or help would be appriciated
Thank you
(can't post the Chrome debugger message rep 10 is requered :-) )
Is windwos.onesignal exactly what you have in your code? Or is this a typo in your post?
All calls to OneSignal should be called by with window.plugins.OneSignal.
Example:
window.plugins.OneSignal.sendTag("key1", "value1");
Check to make sure window.plugins is defined where you're calling OneSignal. It should be called from your onDeviceReady function or add a 'deviceready' listener if you don't have this function. Double check your code with OneSignal's Cordova/PhoneGap install instructions.
You can also send your APK to support#onesignal.com and we can help debug your issue.
Follow the documentation here Make sure you add plugin
> cordova plugin add onesignal-cordova-plugin
And try building it locally.
>ionic build android
If it works locally there is some issue with you config file.Specify version of plugin in config file. Check your installed plugin version.
<plugin name="com.onesignal.plugins.onesignal" spec="1.9.0" source="pgb" />
Hope this helps !
i have a working PhoneGap/Cordova Project Ver 3.5.
i try to work with GA with this plugin, But without success:
https://github.com/danwilson/google-analytics-plugin
i success to install the plugin via this command:
cordova plugin add https://github.com/danwilson/google-analytics-plugin.git
when i try the usage the plugin it faild.
for example:
analytics.startTrackerWithId('UA-XXXX-YY') // UX-2323-23 for example
Any "analytics" function that i try to use fail with error:
"analytics is not defind"
i try via local server - get "analytics is not defind"
i try in simulator - get empty and white screen
i try on Real Device and also get empty and white screen
Please Help :)
Thanks,
Chen.R
First, provide access to external URL using in config.xml <access origin="*" /> then
Put this analytics.startTrackerWithId('UA-XXXX-YY') into onDeviceReady function.
And then you can write your own page names like analytics.trackView('page name');
When you are on the google analytics account, please check the date and time set for view report on right side corner.
Has anyone gotten the clipboard plugin to work with "PhoneGap Build"?
I can't get it to work. I'm currently useing phonegap 3.1.0
My app is for android and IOS. I've only tested the clipboard plugin on android so far, and it isn't working.
in my config.xml:
<gap:plugin name="com.verso.cordova.clipboard" />
in my javascript:
window.plugins.clipboard.copy('some text',function(){alert('success');},function(response){alert('error:' + response);});
window.plugins.clipboard.paste(function(text){alert('paste success:' + text);},function(response){alert('paste error:' + response);});
The way I have it above, the script runs, but for both the copy and paste calls, the error function is executed and the response is "Class not found".
I have tried the above call window.plugins.copy, cordova.plugins.copy
both of those just cause the script to abort.
phonegap is loading just fine and the deviceready function has already fired before I attempt the above calls.
Under the plugins tab on the phonegap build webpage for my app:
Installed 3rd Party Plugins
com.verso.cordova.clipboard 0.1.0
This appears to be unrelated to the copy/paste plugin. In phonegap 3.1 you have to reference all the phonegap plugins you want to use. In this case, I'm guessing you have a function that checks if the user has an internet connection? If so, you need to add to your config.xml
I recently upgraded my app from Phonegap 1.6 to 2.2.
I've refactored everything (ex Plugin --> CordovaPlugin) and I'm also using the new config.xml.
The app compiles and builds, however I constantly am getting an error in logcat and an error dialog box. The dialog says [ERROR] Error initializing Cordova: Class not found.
The logcat error is:
Line 6048 : Error initializing Network Connection: Class not found
What could I be missing?
The issue happens on multiple devices.
Update
I've already changed the config.xml for the network status plugin from Network Status to NetworkStatus. It reads: <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
I had this problem and made it go away by adding the following to the config.xml:
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
And adding this to the Manifest file:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
I originally took them out because I "knew" that my app wouldn't be using any communications. I had forgotten about the emulator "communicating" with the ADK.
I'll take these 2 lines out when I convert the project over to "production" so that the app is ready for Google Play.
I had this problem using phonegap 3.x and the problem turned out to be that phonegap hadn't properly installed the plugins, or they just messed up along the way. Basically when you install the plugins and build for a platform it takes the javascript files from plugins/org.apache.cordova.core.specific-plugin/www and puts them in platforms/android/assets/www/plugins/org.apache.cordova.core.specific-plugin/www and then it takes the Java files (or objective C for iOS) and puts them in platforms/android/src/org/apache/cordova/specificplugin
And all of this is specified by plugins/org.apache.cordova.core.specific-plugin/plugin.xml. If you look in a plugins.xml you should see something like:
<source-file src="src/android/NetworkManager.java" target-dir="src/org/apache/cordova/networkinformation" />
So this tells you that in platforms/android/src/org/apache/cordova/networkinformation, there should be NetworkManager.java. And right that file can be copied from plugins/org.apache.cordova.core.network-information/src/android/NetworkManager.java
Now all of this is supposed to happen automatically without having to touch the platforms folder. But if it messes up you can fix it by copying the correct java files into the correct folders.
The following line in config.xml works for cordova 6.2 with android
<plugin name="cordova-plugin-network-information" value="org.apache.cordova.networkinformation"/>
The name should be the same as in what your plugin contains. You can find it in the your project folder at the following path plugins/name-of-the-plugin/package.json.
The value should be the package name for the plugin which can be found in the native implementation file.