pwa-builder / PWABuilder-CLI

Node.js tool for App Generation
Other
1.63k stars 142 forks source link

Vanilla project generation not working on android #191

Closed mattwoberts closed 8 years ago

mattwoberts commented 8 years ago

This seems to be a recent thing, I've done this tonnes of times in the past without issue.

To recreate

  1. Make sure you're using the latest manifoldjs generator tool.
  2. Generate a new project for android:
manifoldjs http://bbc.co.uk -s bbcMobile
cd bbcMobile\cordova
cordova build android
cordova run anroid --device

Result: App quits with 'There was a network error (http://bbc.co.uk)'

Tried with a bunch of different URLs, and verified that the network connection on the phone is working fine

mattwoberts commented 8 years ago

There's definately something amiss here.

I tested with some of the old projects generated a few weeks ago. They all work fine, both using crosswalk and not using crosswalk.

Now, using the latest bits, if you attempt to generate and run an android project without using crosswalk, you get the error reported above and the app quits.

If you attempt to use the crosswalk plugin, you don't get that error, but you just get a white page with no content, and a spew of warnings.

Looks like it's something that's changed in the ManifoldCordova plugin, let me know if you need more info

boyofgreen commented 8 years ago

Hi Matt, we'll look into this right away. Your on Windows 10 correct?

boyofgreen commented 8 years ago

Fernando, I am getting this same issue on a mac. using latest version and URL https://www.noradsanta.org with no other changes. White page, times out, shows offline message

f2bo commented 8 years ago

@boyofgreen I ran a quick test on a Mac against the site you mention (NoradSanta) and did not see the same problem. The site seems to be working, music included :). I cannot test Android at the moment. I can probably do that later today, or more probably tomorrow.

This may be unrelated but I noticed that upgrading ManifoldJS (and Cordova) in the Mac to the latest version gave me a lot of NPM errors when I upgraded over the previous version. I had to uninstall ManifoldJS and then install it again. Did your installation complete without any errors?

image

boyofgreen commented 8 years ago

yes you are right, it is working for me. It turns out that my Mac was just truly offline. Sorry I jumped the gun. @mattwoberts can you give me some details on your system. When you type in cordova -v what do you get for the version?

mattwoberts commented 8 years ago

I'm on windows 10 (build 10586 although I don't think that's relevant). I uninstalled manifoldjs and re-installed without any errors.

Cordova: 5.3.1 - I haven't updated that for a few weeks now I think.

I think that it's something to do with the new api whitelisting in the ManifoldCordova project, although I've not looked into it any more.

Is OSX (I'm running on a mac), everything works fine for me when I use an ios device

mattwoberts commented 8 years ago

Just trying re-installing all the manifoldjs bits, here's a log if it's useful:

C:\dev>npm uninstall -g manifoldjs
unbuild manifoldjs@0.4.3

C:\dev>npm install -g manifoldjs
npm WARN deprecated lodash@2.4.2: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^3.0.0.
npm WARN deprecated CSSselect@0.4.1: the module is now available as 'css-select'
npm WARN deprecated CSSwhat@0.4.7: the module is now available as 'css-what'
C:\Users\Matt\AppData\Roaming\npm\manifoldjs -> C:\Users\Matt\AppData\Roaming\npm\node_modules\manifoldjs\manifoldjs.js
manifoldjs@0.4.3 C:\Users\Matt\AppData\Roaming\npm\node_modules\manifoldjs
├── ncp@2.0.0
├── q@1.4.1
├── tv4@1.2.7
├── commander@2.9.0 (graceful-readlink@1.0.1)
├── semver@4.3.6
├── loglevel@1.4.0
├── mkdirp@0.5.1 (minimist@0.0.8)
├── request@2.67.0 (is-typedarray@1.0.0, forever-agent@0.6.1, aws-sign2@0.6.0, caseless@0.11.0, stringstream@0.0.5, tunnel-agent@0.4.1, oauth-sign@0.8.0, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, node-uuid@1.4.7, combined-stream@1.0.5, qs@5.2.0, tough-cookie@2.2.1, form-data@1.0.0-rc3, mime-types@2.1.8, bl@1.0.0, har-validator@2.0.3, http-signature@1.1.0, hawk@3.1.2)
├── hwa@0.0.4 (yargs@3.30.0)
├── cheerio@0.18.0 (dom-serializer@0.0.1, entities@1.1.1, htmlparser2@3.8.3, CSSselect@0.4.1, lodash@2.4.2)
├── cloudappx-server@0.0.4 (cors@2.7.1, rimraf@2.4.4, express@4.13.3, unzip@0.1.11, unzip2@0.2.5, multer@0.1.8)
├── archiver@0.14.4 (buffer-crc32@0.2.5, lazystream@0.1.0, async@0.9.2, readable-stream@1.0.33, tar-stream@1.1.5, zip-stream@0.5.2, glob@4.3.5, lodash@3.2.0)
└── cordova@5.4.1 (ansi@0.3.0, underscore@1.7.0, q@1.0.1, nopt@3.0.1, update-notifier@0.5.0, cordova-lib@5.4.1)

And now creating a new app:

C:\dev>manifoldjs http://bbc.co.uk -s bbcMobilenew
WARNING: No manifest found. A new manifest will be created.
WARNING: Manifest validation  (Windows) - A small square logo of any of the following sizes is required for Windows: 24x24, 30x30, 42x42, 54x54[icons]
WARNING: Manifest validation  (Windows) - A splash screen logo of any of the following sizes is required for Windows: 620x300, 868x420, 1116x540[icons]
WARNING: Manifest validation  (Windows) - A square logo of any of the following sizes is required for Windows: 120x120, 150x150, 210x210, 270x270[icons]
WARNING: Manifest validation  (Windows) - A store logo of any of the following sizes is required for Windows: size 50x50, 70x70, 90x90[icons]
WARNING: Manifest validation  (Windows) - An app icon of any of the following sizes is required for Windows Phone: 44x44, 62x62, 106x106[icons]
WARNING: Manifest validation  (Windows) - A medium tile logo of any of the following sizes is required for Windows Phone: 150x150, 210x210, 360x360[icons]
WARNING: Manifest validation  (Windows) - A small tile logo of any of the following sizes is required for Windows Phone: 71x71, 99x99, 170x170[icons]
WARNING: Manifest validation  (Windows) - A store logo of any of the following sizes is required for Windows Phone: 50x50, 70x70, 120x120[icons]
WARNING: Manifest validation  (Android) - Launcher icons of the following sizes are required: 48x48, 72x72, 96x96, 144x144, 192x192, 512x512[icons]
WARNING: Manifest validation  (iOS) - An app icon of the following sizes is required: 76x76, 120x120, 152x152 and 180x180[icons]
WARNING: Manifest validation  (iOS) - An 1024x1024 app icon for the App Store is required[icons]
WARNING: Manifest validation  (iOS) - A launch image of the following sizes is required: 750x1334, 1334x750, 1242x2208, 2208x1242, 640x1136, 640x960, 1536x2048, 2048x1536, 768x1024 and 1024x768[icons]
SUGGESTION: Manifest validation  (Chrome) - A 48x48 icon should be provided for the extensions management page (chrome://extensions)[icons]
SUGGESTION: Manifest validation  (Chrome) - It is recommended to have a 16x16 favicon[icons]
WARNING: Manifest validation  (Chrome) - A 128x128 icon is required for the installation process and the Chrome Web Store[icons]
SUGGESTION: Manifest validation  (Firefox) - Firefox 2.0 onwards, an 512x512 icon is recommended for Firefox Marketplace and devices[icons]
WARNING: Manifest validation  (Firefox) - A 128x128 icon is required for the Firefox Marketplace and the devices[icons]
SUGGESTION: Manifest validation  (Firefox) - It is recommended to provide icon sizes for multiple platforms, including: 16x16, 32x32, 48x48, 64x64, 90x90, 128x128 and 256x256[icons]
SUGGESTION: Manifest validation  (All Platforms) - It is recommended to specify a set of rules that represent the navigation scope of the application[mjs_extended_scope]

C:\dev\bbcMobilenew\cordova>cordova -v
5.3.1

C:\dev\bbcMobilenew\cordova>cordova plugins list
cordova-plugin-hostedwebapp 0.2.1 "HostedWebApp"
cordova-plugin-network-information 1.1.0 "Network Information"
cordova-plugin-whitelist 1.0.0 "Whitelist"

Finally, running the app:

BUILD SUCCESSFUL

Total time: 5.03 secs
Built the following apk(s):
    C:\dev\bbcMobilenew\cordova\platforms\android\build\outputs\apk\android-debug.apk
Using apk: C:\dev\bbcMobilenew\cordova\platforms\android\build\outputs\apk\android-debug.apk
Installing app on device...
Launching application...
LAUNCH SUCCESS

And the result:

screenshot_2015-12-03-09-34-07

f2bo commented 8 years ago

This one was tough and had me really confused. The steps to reproduce the problem are:

manifoldjs http://bbc.co.uk -s bbcMobilenew -l debug
cd bbcMobilenew\cordova
cordova run android

Depending on the version of Cordova that you have installed globally you might see a "There was a network error" message.

It seems that the problem is mixing Cordova versions. ManifoldJS uses a private copy of Cordova to ensure that it uses a version that has been tested. Typically, you also have Cordova installed globally, and it might be a different version than the one used by ManifoldJS.

When you run Cordova commands from the command line against a ManifoldJS generated project, it will use the global version of Cordova instead of the version that was used to generate the app. In the latest Cordova release(s), they must have changed the way they handle the configuration data and mixing versions results in the config.xml file being corrupted.

We've always wanted to create a wrapper for the Cordova commands so that you could execute manifoldjs cordova <xxx> (or some other variant) and that would delegate the execution of the command to the private copy of Cordova . We've talked about this many times and never addressed the problem because it didn’t have any negative side effects. That is, until now.

For the time being, you have a couple of options:

mattwoberts commented 8 years ago

@f2bo Thanks for that! I've been without power (!) for a while so unable to check this, I'll have a look now :)

mattwoberts commented 8 years ago

All good now - I've just simply updated my cordova to match.

I presume this could be an issue though if you update manifoldjs again to use a different version - so using the private version does make sense.