nordnet / cordova-hot-code-push-cli

[DEPRECATED] - This is a command line utility for Cordova Hot Code Push Plugin.
https://github.com/nordnet/cordova-hot-code-push-cli/issues/79
144 stars 139 forks source link

Page can't change in emulators #45

Closed NexusLee closed 6 years ago

NexusLee commented 8 years ago

I built a cordova project. cd demo, cordova-hcp server. then cordova run. Modify the index.html but the app do not change. Am I missing anything? image

NexusLee commented 8 years ago

And I am on windows

NexusLee commented 8 years ago

According to https://github.com/nordnet/cordova-hot-code-push-local-dev-addon/issues/5, I finally got the "a user connected" in the command line, but it still cant refresh automatically in the emulator.

NexusLee commented 8 years ago

And my chcp.json is still xxx.ngrok.com

nikDemyankov commented 8 years ago

As I understand, you have done everything, as described in tutorial.

  1. Make sure, that https://xxx.ngrok.com/chcp.json is accessible from your emulator.
  2. Make sure, that https://xxx.ngrok.com/chcp.manifest is accessible from your emulator.
  3. Make sure, that paths in chcp.manifest are relative to the www folder and doesn't hold \. There might be a problem with that on windows.
  4. Open your project in IDE (probably this is Android - then use Android Studio), and run it from there. Look into console for any messages from the plugin. It should log errors/success events.
NexusLee commented 8 years ago

Modify the chcp.json and it will change to ngrok.com at last

NexusLee commented 8 years ago

@nikDemyankov ngrok.com is blocked. So I change ngrok.com to my local IP in afterPrepareHook.js. But the chcp.json is still ngrok.com.

nikDemyankov commented 8 years ago

If ngrok is blocked - you can use some other local server, that will serve your www files, as mentioned in https://github.com/nordnet/cordova-hot-code-push-local-dev-addon/issues/5.

In that case you can still use local development add-on to automatically trigger page reload. Just make sure, that config-file url is set to the correct address in your platform-specific config.xml (probably this is what you do in afterPrepareHook.js). Also, create cordova-hcp.json file in the root folder of your Cordova project, and define there:

{
  "content_url": "http://<YOUR_LOCAL_SERVER_ADDRESS>/"
}

And after each change you do - execute cordova-hcp build to refresh content of the config files in www.

NexusLee commented 8 years ago

I am sorry. I read your comment over and over again, but I still don't know clearly what the local server can help? I created cordova-hcp.json and I execute cordova-hcp build after each change in www. And the content_url is my local IP address in chcp.json now. Can u tell me how the local server do to www files. Thanks.

nikDemyankov commented 8 years ago

Have you checked all, what is described in https://github.com/nordnet/cordova-hot-code-push-cli/issues/45#issuecomment-191142511 ?

You can get update logs from Android Studio. Just launch Android Studio, click Open an existing Android Studio project and select E:\work\cordova\demo\platforms\android. Then from it launch the app on the emulator/device and look into the logs, displayed in the studio. There you should see logs with tag CHCP. If update has failed for some reason - you should see it in there.

NexusLee commented 8 years ago

@nikDemyankov About this I didn't use android studio before, but finally I got this error. It's a parse error.

03-03 21:05:27.643 2912-3022/io.cordova.hellocordova D/CHCP﹕ New Release is available 03-03 21:05:27.660 2912-3023/io.cordova.hellocordova D/CHCP﹕ Starting loader worker 03-03 21:05:27.684 2912-3023/io.cordova.hellocordova D/CHCP﹕ Failed to convert json string into application config com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: <!DOCTYPE HTML>

Cordova App Loader

sssssssssssssss

; line: 1, column: 2] at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1419) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:508) at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:437) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1462) at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:683) at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3105) at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3051) at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:1833) at com.nordnetab.chcp.main.config.ApplicationConfig.fromJson(ApplicationConfig.java:48) at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.createInstance(ApplicationConfigDownloader.java:26) at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.createInstance(ApplicationConfigDownloader.java:13) at com.nordnetab.chcp.main.network.JsonDownloader.download(JsonDownloader.java:50) at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.download(ApplicationConfigDownloader.java:13) at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.downloadApplicationConfig(UpdateLoaderWorker.java:165) at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.run(UpdateLoaderWorker.java:75) at com.nordnetab.chcp.main.updater.UpdatesLoader$1.run(UpdatesLoader.java:61) at java.lang.Thread.run(Thread.java:818) 03-03 21:05:27.684 2912-3023/io.cordova.hellocordova D/CHCP﹕ Failed to update

image

nikDemyankov commented 8 years ago

Failed to convert json string into application config com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')

This means, that chcp.json is some html page, not a json config. Most likely, it's just not found on the server. That's why no update is coming.

So you need to make sure, that emulator can reach chcp.json. Open YOUR_PROJECT_DIR/platforms/android/res/xml/config.xml and check, what is set as config-file url. Then on the emulator open browser, and try to open that url. It should be a json config.

But as you have read in https://github.com/nordnet/cordova-hot-code-push-local-dev-addon/issues/5 - other developer also tried to use ip as a server address, but eventually switched to some simple server, written on python. So, maybe, if ngrok is blocked for you and emulator can't reach server by ip - this is what you should try to do.

nordnet-deprecation-bot commented 6 years ago

👋 Hi! Thank you for your interest in this repo.

😢 We are not using nordnet/cordova-hot-code-push-cli anymore, and we lack the manpower and the experience needed to maintain it. We are aware of the inconveniece that this may cause you. Feel free to use it as is, or create your own fork.

🔒 This will now be closed & locked.

ℹ️ Please see #79 for more information.