3 Replies Latest reply on Jun 23, 2016 1:07 PM by jlzaroo

    3rd party plugins all undefined


      I can't seem to get any 3rd party plugin working in my app. I've been using the online phonegap builder on build.phonegap.com. When I debug the app on an android phone through gapdebug, I get messages like:

      "cannot read property barcodeScanner of undefined."


      everything else seems to work fine apart but only when a 3rd party plugin is called, it says its undefined... I've tried about everything but I can't seem to find what's wrong.


      My config file:

      <?xml version="1.0" encoding="UTF-8" ?>

      <widget xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0" id="com.test.testapp" version="1.0.0" xmlns:android="http://schemas.android.com/apk/res/android">



        <author href="http://test.com" email="test@test.com">test</author>


        <preference name="permissions" value="none"/>

        <preference name="orientation" value="default"/>

        <preference name="target-device" value="universal"/>

        <preference name="Fullscreen" value="false"/>

        <preference name="webviewbounce" value="true"/>

        <preference name="prerendered-icon" value="true"/>

        <preference name="stay-in-webview" value="false"/>

        <preference name="ios-statusbarstyle" value="black-opaque"/>

        <preference name="detect-data-types" value="true"/>

        <preference name="exit-on-suspend" value="false"/>

        <preference name="show-splash-screen-spinner" value="true"/>

        <preference name="auto-hide-splash-screen" value="true"/>

        <preference name="disable-cursor" value="false"/>

        <preference name="android-minSdkVersion" value="14"/>

        <preference name="android-installLocation" value="auto"/> 


        <preference name="android-build-tool" value="gradle"/>  


        <gap:config-file platform="android" parent="/manifest">

          <application android:debuggable="true"/>


        <gap:plugin name="org.apache.cordova.camera" spec="0.3.6" source="pgb"/>

        <gap:plugin name="org.apache.cordova.media-capture"/>

        <gap:plugin name="org.apache.cordova.console"/>

        <gap:plugin name="org.apache.cordova.contacts"/>

        <gap:plugin name="org.apache.cordova.device"/>

        <gap:plugin name="org.apache.cordova.dialogs"/>

        <gap:plugin name="org.apache.cordova.file"/>

        <gap:plugin name="org.apache.cordova.file-transfer"/>

        <gap:plugin name="org.apache.cordova.geolocation"/>

        <gap:plugin name="org.apache.cordova.inappbrowser"/>

        <gap:plugin name="org.apache.cordova.media"/>

        <gap:plugin name="org.apache.cordova.network-information"/>

        <gap:plugin name="org.apache.cordova.splashscreen"/>

        <gap:plugin name="org.apache.cordova.vibration"/>


          <plugin name="cordova-plugin-imagepicker" source="npm"/>

          <plugin name="phonegap-plugin-barcodescanner" />


        <icon src="res/icon/ios/icon-57-2x.png"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="android" gap:qualifier="ldpi"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="android" gap:qualifier="mdpi"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="android" gap:qualifier="hdpi"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="android" gap:qualifier="xhdpi"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="android" gap:qualifier="xxhdpi"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="blackberry"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="blackberry" gap:state="hover"/>

        <icon src="res/icon/ios/icon-57.png" gap:platform="ios" width="57" height="57"/>

        <icon src="res/icon/ios/icon-72.png" gap:platform="ios" width="72" height="72"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="ios" width="114" height="114"/>

        <icon src="res/icon/ios/icon-72-2x.png" gap:platform="ios" width="144" height="144"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="webos"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="winphone"/>

        <icon src="res/icon/ios/icon-57-2x.png" gap:platform="winphone" gap:role="background"/>



        <access origin="*"/>

        <plugin name="cordova-plugin-whitelist" source="npm"/>

        <allow-intent href="http://*/*"/>

        <allow-intent href="https://*/*"/>

        <allow-intent href="tel:*"/>

        <allow-intent href="sms:*"/>

        <allow-intent href="mailto:*"/>

        <allow-intent href="geo:*"/>

        <platform name="android">

          <allow-intent href="market:*"/>


        <platform name="ios">

          <allow-intent href="itms:*"/>

          <allow-intent href="itms-apps:*"/>





      excerpt from the index.html:

      <script type="text/javascript" src="cordova.js"></script>
      <script type="text/javascript" src="barcodescanner.js"></script>
      <script type="text/javascript" src="imagepicker.js"></script>


      <script type="text/javascript" src="js/index.js"></script>



      <script type="text/javascript">




      I'm calling the 3rd party plugins using functions that are called onclick of a button within the app:


      function barcodeScan() {


      // I've tried it with cordova.plugins, window.plugins, window.plugin, etc. All returns the same.


            function (result) {

                console.log("We got a barcode\n" +

                      "Result: " + result.text + "\n" +

                      "Format: " + result.format + "\n" +

                      "Cancelled: " + result.cancelled);


            function (error) {

                console.log("Scanning failed: " + error);





      function getMultiplePhotos() {

          cordova.plugins.imagePicker.getPictures(function(results) {

              for (var i = 0; i < results.length; i++) {

                  console.log("Image URI: "+results[i]);


          }, function(error) {

              console.log("Error: "+error);


              maximumImagesCount: 10,

              width: 1600



        • 1. Re: 3rd party plugins all undefined
          jlzaroo Level 1

          I think I found the issue after 2 weeks of pulling out my hair. For anyone experiencing this issue, hopefully this will save you the aggravation and time. In using phonegap builder, I've also enabled hydration which allows the app to pull in updates and 'self-update' without having to reinstall the apk or ipa file. I completely removed the app and reinstalled it manually without relying on hydration and it resolved all the issues.


          I think there is an issue with hydration in correctly adding plugin support files and adding in the libraries and it was causing unnecessary problems.

          • 2. Re: 3rd party plugins all undefined
            shotts@adobe Adobe Employee

            Note that Hydration does not support changes to plugins or config.xml after building. Hydration is suitable for web content changes only. So if you add (remove/change) a plugin or make an adjustment to config.xml, you need to rebuild the app and reinstall it on your device(s).

            • 3. Re: 3rd party plugins all undefined
              jlzaroo Level 1

              Yes, no kidding. I learned that the hard way. I didn't see that mentioned anywhere in the phonegap documentation. Maybe I missed it but that should definitely be highlighted somewhere as it's a bit misleading as to what it hydrates.


              I also am seeing that the build log in phonegap builder does not update always. Documentation on this is severely lacking...