6 Replies Latest reply on Jan 8, 2017 7:58 AM by VectorP

    index.html won't load <scripts



      I build a phonegap app with the desktop builder and it works fine.

      when i decided to build it into an apk it won't load the first script.


          <script type="text/javascript" src="cordova.js"></script>
          <script type="text/javascript" src="lib/framework7/js/framework7.min.js"></script>
          <script type="text/javascript" src="js/my-app.js"></script>
              if (window.localStorage.getItem("btag") != null) window.location.href = "chat.html";
              else window.location.href = "login.html";


      this simple script redirects the client to a chat page if he has some value stored in his local storage,

      and if he doesn't have it will send him to log into the app and get that value embeded to his local storage.

      but in here, the client isn't getting redirected for some reason.


      this code works when run at the desktop builder, it just won't work when building the code into an apk.


      anyone can help?

        • 1. Re: index.html won't load <scripts
          kerrishotts Adobe Employee

          How are you building your app?


          What devices & OS versions are you testing on?


          Do you have a Content-Security-Policy meta tag in your index.html file? If so, what is it?


          What does your config.xml look like (minus identifying/secret information)?

          • 2. Re: index.html won't load <scripts
            orele21060075 Level 1

            im am building the app by uploading the files to the phoengap website.

            device is note 4 on android.



                <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">

                <!-- Required meta tags-->

                <meta charset="utf-8">

                <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">

                <meta name="apple-mobile-web-app-capable" content="yes">

                <meta name="apple-mobile-web-app-status-bar-style" content="black">

                <meta name="format-detection" content="telephone=no">

                <meta name="msapplication-tap-highlight" content="no">



            <?xml version='1.0' encoding='utf-8'?>
            <widget id="co.il.owisrael.messages" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
                <name>Overwatch Israel Instant Messages</name>
                    A basic Framework7 template for PhoneGap.
                <author email="dev@cordova.apache.org" href="http://cordova.io">
                    Apache Cordova Team
                <content src="index.html" />
                <access origin="*" />   
                <allow-navigation href="https://blzgdapipro-a.akamaihd.net/*" />.
                <access origin="https://blzgdapipro-a.akamaihd.net" />
                <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">
                    <preference name="android-minSdkVersion" value="14" />
                    <allow-intent href="market:*" />
                <platform name="ios">
                    <allow-intent href="itms:*" />
                    <allow-intent href="itms-apps:*" />
                    <preference name="BackupWebStorage" value="none" />
                <preference name="DisallowOverscroll" value="true" />
                <plugin name="cordova-plugin-battery-status" source="npm" spec="~1.1.1" />
                <plugin name="cordova-plugin-camera" source="npm" spec="~2.1.1" />
                <plugin name="cordova-plugin-media-capture" source="npm" spec="~1.2.0" />
                <plugin name="cordova-plugin-console" source="npm" spec="~1.0.2" />
                <plugin name="cordova-plugin-contacts" source="npm" spec="~2.0.1" />
                <plugin name="cordova-plugin-device" source="npm" spec="~1.1.1" />
                <plugin name="cordova-plugin-device-motion" source="npm" spec="~1.2.0" />
                <plugin name="cordova-plugin-device-orientation" source="npm" spec="~1.0.2" />
                <plugin name="cordova-plugin-dialogs" source="npm" spec="~1.2.0" />
                <plugin name="cordova-plugin-file" source="npm" spec="~4.1.1" />
                <plugin name="cordova-plugin-file-transfer" source="npm" spec="~1.5.0" />
                <plugin name="cordova-plugin-geolocation" source="npm" spec="~2.1.0" />
                <plugin name="cordova-plugin-globalization" source="npm" spec="~1.0.3" />
                <plugin name="cordova-plugin-inappbrowser" source="npm" spec="~1.3.0" />
                <plugin name="cordova-plugin-media" source="npm" spec="~2.2.0" />
                <plugin name="cordova-plugin-network-information" source="npm" spec="~1.2.0" />
                <plugin name="cordova-plugin-splashscreen" source="npm" spec="~3.2.1" />
                <plugin name="cordova-plugin-statusbar" source="npm" spec="~2.1.2" />
                <plugin name="cordova-plugin-vibration" source="npm" spec="~2.1.0" />
                <plugin name="cordova-plugin-whitelist" source="npm" spec="~1.2.1" />
            • 3. Re: index.html won't load <scripts
              orele21060075 Level 1

              Anyone knows why this is happening?

              • 4. Re: index.html won't load <scripts
                VectorP Level 4

                Not sure what's happenening here.

                In your initial post, you say:

                it won't load the first script.

                Then you have some code, where the first referenced script is:

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

                Are you saying that this is not loaded somehow?


                Should you be refering to this

                1. if (window.localStorage.getItem("btag") != null) window.location.href = "chat.html"
                2.         else window.location.href = "login.html";


                - are you sure this part of your code is reached and executed at all?

                - if so, what is the value of 'btag' when testing?



                And just a bit of feedback on your config:

                a. You are using many plugins. Do you really need them all?

                b. You are setting plugin versions. Why? And why are they partly pinned to older versions?

                c. You don't need the file plugin if you already have the file-transfer plugin.

                d. You have no icons and splashes. They are, however, mandatory for iOS and strongly recommended for Android.




                • 5. Re: index.html won't load <scripts
                  orele21060075 Level 1

                  Thanks for the reply,

                  Sorry for the mess I created here, I will try to be more focused on the problem.

                  The only problem that I am getting, is that the app won't move the client to the next pages (chat.html and login.html).

                  When I'm connecting to the app via the desktop app builder (and the phonegap app) I'm getting redirected instantly, but when I compiled it to an apk and installed it on my phone (and other android phone) it won't redirect to the next page.


                  And for the config.xml, I know it's a mess, I'm just testing the app, and will configure it on realese.

                  • 6. Re: index.html won't load <scripts
                    VectorP Level 4

                    - are you sure this part of your code is reached and executed at all?

                    - if so, what is the value of 'btag' when testing?


                    I'm just testing the app, and will configure it on realese

                    So, you will be testing everything again, then? Wouldn't you rather test it initially with the configuration you'd need upon release?