Using plugins...

10 posts, 0 answers
  1. Alfredo
    Alfredo avatar
    27 posts
    Member since:
    Apr 2012

    Posted 08 Jul 2013 Link to this post

    Hi,

    I'm trying to implement the Facebook plugin into my App. Apparently the plugin is plugman-compliant. It contains a plugin.xml that follows the plugman specs. However I'm confused about how this plugin can be made to work since there are other requirements besides the plugin.xml which in turn also requires some tweaking as correcting some file paths.

    The included plugins are somewhat very simple to work as examples for other plugin integration. According to the Facebook plugin documentation it requires adding extra lines to the androidManifest.xml and config.xml files.

    So question is: Should these extra requirements be made/included in the project or should the plugin be imported and left alone?

    Thank you!
  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 08 Jul 2013 Link to this post

    Hello Alfredo,

     A plugin's plugin.xml should contain all the necessary transformations that need to take place in AndroidManifest.xml, Info.plist and config.xml.

     However, the FacebookConnect plugin is an exception. In FacebookConnect's plugin.xml there are two placeholder values that need to replaced with their actual value so that Icenium can build your app. When you open the plugin.xml file, look for these lines:
    <preference name="APP_ID" />
    <preference name="APP_NAME" />

     They indicate to plugman that a couple of parameters should be passed when installing the plugin. Delete those two lines and replaces any occurrences of $APP_ID and $APP_NAME in the plugin.xml file with their actual values as obtained from the Facebook developer dashboard.

     Other than that, the plugin should build fine. Please let me know if you need assistance and I'll help you as best as I can.

    Regards,
    Yavor Georgiev
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  3. Alfredo
    Alfredo avatar
    27 posts
    Member since:
    Apr 2012

    Posted 08 Jul 2013 Link to this post

    Yavor,

    All right I only see the <preference name="APP_ID" /> as well as <plugin name="..." value="..."/> whose target is config.xml, however plugin's manual android installation instructions advise to place an extra <activity /> in androidManifest.xml and don't see a reference  to it in plugin.xml.

    Should I just ignore that? plugin.xml seems to need some work since paths are all wrong. Also, should the unziped plugin be left as is or can the examples folder be deleted?
  4. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 08 Jul 2013 Link to this post

    Hello Alfredo,

     Are you by any chance using this plugin? If so, yes, then you need to make sure all paths begin with /src/ios or /src/android where appropriate. It appears that this plugin hasn't been updated to work with the plugman we use - 0.7.7. For some reason Cordova have dropped the implicit platform paths feature present in earlier versions of plugman. I'd suggest trying the FacebookConnect plugin, too, as its plugin.xml is in line with the current version of the spec.

     Regarding LoginActivity: adding this activity appears to be an optional step and perhaps this is why it was not added in the plugin.xml. You can add the following to the android platform in plugin.xml:
    <config-file target="AndroidManifest.xml" parent="/manifest/application">
        <activity android:name="com.facebook.LoginActivity" android:label="@string/app_name" />
    </config-file>

     Or you can edit your AndroidManifest.xml manually to add this activity yourself. To do so simply right-click on your project in Project Navigator and choose the Android Manifest option from the Edit Configuration menu.

    Regards,
    Yavor Georgiev
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  5. Alfredo
    Alfredo avatar
    27 posts
    Member since:
    Apr 2012

    Posted 08 Jul 2013 Link to this post

    Yavor,

    I'm using the FacebookConnect plugin since, as you point out, is more capable and better updated. However it also required  the paths to be updated exactly as you advise. Ok, I'm going to add the "activity" to the AndroidManifest.xml and test.

    Two more questions please:

    1. Manual Android Installation requires ConnectPlugin.java to be copied to src/org/apache/cordova/facebook. Do you think this should also be done in this case? as don't see this to be implemented by plugin.xml.

    2. When importing the plugin everything was put in the project file tree, including the examples provided by the plugin. I see no reason for them to be there, can they be removed (erased)?

    Thanks a lot for your help!

  6. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 08 Jul 2013 Link to this post

    Hello Alfredo,

     ConnectPlugin.java is referenced in the plugin.xml file - right here.

     You can safely delete all examples and other files from the plugin folder. Only the files described in plugin.xml are relevant.

    Regards,
    Yavor Georgiev
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  7. Alfredo
    Alfredo avatar
    27 posts
    Member since:
    Apr 2012

    Posted 08 Jul 2013 Link to this post

    Thank you the response. You know the two plugins are so similar to each other that somehow ended up using the wrong one.
    Everything looks so much clearer now, Thank you. I'm going to replace  the plugin with the more desirable one (Facebook Connect).
    Now I'll try to add push notifications to the App.

    Thanks again and keep up with the good work!
  8. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 09 Jul 2013 Link to this post

    Hello Alfredo,

     Thank you for your kind words. Please don't hesitate to let us know if you need assistance.

    Regards,
    Yavor Georgiev
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Missed our first webinar, watch it here.
    Share feedback and vote for features on our Feedback Portal.
  9. Roberto
    Roberto avatar
    1 posts
    Member since:
    Aug 2013

    Posted 07 Aug 2013 Link to this post

    help me plese... i have  more problems with fb plugin . . . .
    i have a 52 errors!

    if use the plugman tell me:
    grafting xml at selector "plugins" from "C:\test\platforms\android\res\xml\config.xml" during config install went bad :(

    and when made a ant install i have 52 errors...

    [javac]         PluginResult pr = new PluginResult(PluginResult.Status.NO_RE
    SULT);
        [javac]                                                        ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:50: error: cannot find symbol
        [javac]                 SharedPreferences prefs = PreferenceManager.getDefau
    ltSharedPreferences(cordova.getActivity());
        [javac]
                        ^
        [javac]   symbol:   variable cordova
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:73: error: cannot find symbol
        [javac]                     return new PluginResult(PluginResult.Status.OK,
    this.getResponse());
        [javac]                                ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:73: error: package PluginResult does not exist
        [javac]                     return new PluginResult(PluginResult.Status.OK,
    this.getResponse());
        [javac]                                                         ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:76: error: cannot find symbol
        [javac]                     return new PluginResult(PluginResult.Status.NO_R
    ESULT);
        [javac]                                ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:76: error: package PluginResult does not exist
        [javac]                     return new PluginResult(PluginResult.Status.NO_R
    ESULT);
        [javac]                                                         ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:81: error: cannot find symbol
        [javac]                 return new PluginResult(PluginResult.Status.ERROR, "
    Invalid JSON args used. expected a string as the first arg.");
        [javac]                            ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:81: error: package PluginResult does not exist
        [javac]                 return new PluginResult(PluginResult.Status.ERROR, "
    Invalid JSON args used. expected a string as the first arg.");
        [javac]                                                     ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:96: error: cannot find symbol
        [javac]                     return new PluginResult(PluginResult.Status.ERRO
    R, "Invalid JSON args used. Expected a string array of permissions.");
        [javac]                                ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:96: error: package PluginResult does not exist
        [javac]                     return new PluginResult(PluginResult.Status.ERRO
    R, "Invalid JSON args used. Expected a string array of permissions.");
        [javac]                                                         ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:98: error: cannot find symbol
        [javac]                 cordova.setActivityResultCallback(this);
        [javac]                 ^
        [javac]   symbol:   variable cordova
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:104: error: cannot find symbol
        [javac]                         me.facebook.authorize(cordova.getActivity(),
     me.permissions, new AuthorizeListener(me));
        [javac]                                               ^
        [javac]   symbol: variable cordova
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:107: error: cannot find symbol
        [javac]                 cordova.getActivity().runOnUiThread(runnable);
        [javac]                 ^
        [javac]   symbol:   variable cordova
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:110: error: cannot find symbol
        [javac]                 pr = new PluginResult(PluginResult.Status.ERROR, "Mu
    st call init before login.");
        [javac]                          ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:110: error: package PluginResult does not exist
        [javac]                 pr = new PluginResult(PluginResult.Status.ERROR, "Mu
    st call init before login.");
        [javac]                                                   ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:117: error: cannot find symbol
        [javac]                     facebook.logout(cordova.getActivity());
        [javac]                                     ^
        [javac]   symbol:   variable cordova
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:119: error: cannot find symbol
        [javac]                     SharedPreferences prefs = PreferenceManager.getD
    efaultSharedPreferences(this.cordova.getActivity());
        [javac]
                                ^
        [javac]   symbol: variable cordova
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:125: error: cannot find symbol
        [javac]                     pr = new PluginResult(PluginResult.Status.MALFOR
    MED_URL_EXCEPTION, "Error logging out.");
        [javac]                              ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:125: error: package PluginResult does not exist
        [javac]                     pr = new PluginResult(PluginResult.Status.MALFOR
    MED_URL_EXCEPTION, "Error logging out.");
        [javac]                                                       ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:129: error: cannot find symbol
        [javac]                     pr = new PluginResult(PluginResult.Status.IO_EXC
    EPTION, "Error logging out.");
        [javac]                              ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:129: error: package PluginResult does not exist
        [javac]                     pr = new PluginResult(PluginResult.Status.IO_EXC
    EPTION, "Error logging out.");
        [javac]                                                       ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:131: error: cannot find symbol
        [javac]                 pr = new PluginResult(PluginResult.Status.OK, getRes
    ponse());
        [javac]                          ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:131: error: package PluginResult does not exist
        [javac]                 pr = new PluginResult(PluginResult.Status.OK, getRes
    ponse());
        [javac]                                                   ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:133: error: cannot find symbol
        [javac]                 pr = new PluginResult(PluginResult.Status.ERROR, "Mu
    st call init before logout.");
        [javac]                          ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:133: error: package PluginResult does not exist
        [javac]                 pr = new PluginResult(PluginResult.Status.ERROR, "Mu
    st call init before logout.");
        [javac]                                                   ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:139: error: cannot find symbol
        [javac]                 pr = new PluginResult(PluginResult.Status.OK, getRes
    ponse());
        [javac]                          ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:139: error: package PluginResult does not exist
        [javac]                 pr = new PluginResult(PluginResult.Status.OK, getRes
    ponse());
        [javac]                                                   ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:141: error: cannot find symbol
        [javac]                 pr = new PluginResult(PluginResult.Status.ERROR, "Mu
    st call init before getLoginStatus.");
        [javac]                          ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:141: error: package PluginResult does not exist
        [javac]                 pr = new PluginResult(PluginResult.Status.ERROR, "Mu
    st call init before getLoginStatus.");
        [javac]                                                   ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:178: error: cannot find symbol
        [javac]                                     me.facebook.dialog (me.cordova.g
    etActivity(), me.method , me.paramBundle , new UIDialogListener(me));
        [javac]                                                           ^
        [javac]   symbol:   variable cordova
        [javac]   location: variable me of type ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:181: error: cannot find symbol
        [javac]                     cordova.getActivity().runOnUiThread(runnable);
        [javac]                     ^
        [javac]   symbol:   variable cordova
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:184: error: cannot find symbol
        [javac]                     pr = new PluginResult(PluginResult.Status.ERROR,
     "Must call init before showDialog.");
        [javac]                              ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:184: error: package PluginResult does not exist
        [javac]                     pr = new PluginResult(PluginResult.Status.ERROR,
     "Must call init before showDialog.");
        [javac]                                                       ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:37: error: method does not override or implement a method from a supert
    ype
        [javac]     @Override
        [javac]     ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:194: error: cannot find symbol
        [javac]         super.onActivityResult(requestCode, resultCode, data);
        [javac]         ^
        [javac]   symbol:   variable super
        [javac]   location: class ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:192: error: method does not override or implement a method from a super
    type
        [javac]     @Override
        [javac]     ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:240: error: cannot find symbol
        [javac]                     this.fba.success(new PluginResult(PluginResult.S
    tatus.OK), this.fba.callbackId);
        [javac]                                          ^
        [javac]   symbol:   class PluginResult
        [javac]   location: class ConnectPlugin.UIDialogListener
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:240: error: package PluginResult does not exist
        [javac]                     this.fba.success(new PluginResult(PluginResult.S
    tatus.OK), this.fba.callbackId);
        [javac]                                                                   ^
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:245: error: cannot find symbol
        [javac]            this.fba.error("Facebook error: " + e.getMessage(), callb
    ackId);
        [javac]                    ^
        [javac]   symbol:   method error(String,String)
        [javac]   location: variable fba of type ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:250: error: cannot find symbol
        [javac]            this.fba.error("Dialog error: " + e.getMessage(), this.fb
    a.callbackId);
        [javac]                    ^
        [javac]   symbol:   method error(String,String)
        [javac]   location: variable fba of type ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:255: error: cannot find symbol
        [javac]            this.fba.error("Cancelled", this.fba.callbackId);
        [javac]                    ^
        [javac]   symbol:   method error(String,String)
        [javac]   location: variable fba of type ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:272: error: cannot find symbol
        [javac]             SharedPreferences prefs = PreferenceManager.getDefaultSh
    aredPreferences(this.fba.cordova.getActivity());
        [javac]
                            ^
        [javac]   symbol:   variable cordova
        [javac]   location: variable fba of type ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:284: error: cannot find symbol
        [javac]                         fba.success(getResponse(), fba.callbackId);
        [javac]                            ^
        [javac]   symbol:   method success(JSONObject,String)
        [javac]   location: variable fba of type ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:302: error: cannot find symbol
        [javac]             this.fba.error("Facebook error: " + e.getMessage(), call
    backId);
        [javac]                     ^
        [javac]   symbol:   method error(String,String)
        [javac]   location: variable fba of type ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:307: error: cannot find symbol
        [javac]             this.fba.error("Dialog error: " + e.getMessage(), this.f
    ba.callbackId);
        [javac]                     ^
        [javac]   symbol:   method error(String,String)
        [javac]   location: variable fba of type ConnectPlugin
        [javac] C:\test\platforms\android\src\org\apache\cordova\facebook\ConnectPlu
    gin.java:312: error: cannot find symbol
        [javac]             this.fba.error("Cancelled", this.fba.callbackId);
        [javac]                     ^
        [javac]   symbol:   method error(String,String)
        [javac]   location: variable fba of type ConnectPlugin
        [javac] Note: Some input files use or override a deprecated API.
        [javac] Note: Recompile with -Xlint:deprecation for details.
        [javac] 52 errors

  10. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 09 Aug 2013 Link to this post

    Hi Roberto,

    Both facebook plugins referred to in this forum thread are not updated to work with Cordova 2.7. As discussed with Alfredo, we would work with the FaceBookConnect plugin as its plugin.xml is in line with the current version of the spec.

    To modify the plugin to work with Cordova 2.7, we have used the suggestion from this blog post: Why Don't My Plugins Work in PhoneGap Android 2.7? For your convenience we have modified the plugin and attached it to this thread. You can download it and import it (see Import Custom Plugins from Archive) into your Icenium project and it would build successfully.

    Regards,
    Steve
    Telerik

    Do you enjoy Icenium? Vote for it as your favorite new product here (use short code H048S).
    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
Back to Top