nordnet / cordova-hot-code-push

[DEPRECATED] - This plugin provides functionality to perform automatic updates of the web based content in your application.
https://github.com/nordnet/cordova-hot-code-push/issues/371
MIT License
979 stars 467 forks source link

Failed to convert json string into application config - FAILED_TO_DOWNLOAD_APPLICATION_CONFIG (Error code -1) #352

Closed vijeth-ag closed 6 years ago

vijeth-ag commented 6 years ago

Integrating Hot Code Push with Ionic v1. Works fine with www folder hosted in any(Local/Remote) with pythonSimpleHTTPServer i,e, chcp.json is accessible.

In production, the www folder is in Nginx environment. The chcp.json production url is accessible via browser directly, but within the app, the chcp.json doesnt seem to accessed well via the plugin. Error logs below

error log from > adb logcat below

04-26 18:23:25.155 5232-5232/com.mobile.app D/SystemWebChromeClient: https://production-server/chcp.json: Line 2 : 
Uncaught SyntaxError: Unexpected token :
04-26 18:23:25.155 5232-5232/com.mobile.app I/chromium: [INFO:CONSOLE(2)] 
"Uncaught SyntaxError: Unexpected token :", source: https://production-server/chcp.json (2)

More error log from adb logact

04-26 19:05:59.765 21350-21470/com.mobile.app D/CHCP: Failed to convert json string into application config com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input at [Source: ; line: 1, column: 1] at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3110) 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:29) at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.createInstance(ApplicationConfigDownloader.java:15) at com.nordnetab.chcp.main.network.JsonDownloader.download(JsonDownloader.java:54) at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.download(ApplicationConfigDownloader.java:15) at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.downloadApplicationConfig(UpdateLoaderWorker.java:173) at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.run(UpdateLoaderWorker.java:74) at com.nordnetab.chcp.main.updater.UpdatesLoader$1.run(UpdatesLoader.java:58) at java.lang.Thread.run(Thread.java:761)

My ionic info ` cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

global packages:

cordova (Cordova CLI) : 8.0.0 
Gulp CLI              : CLI version 3.9.1 Local version 3.9.1

local packages:

Cordova Platforms : android 6.2.3
Ionic Framework   : unknown

System:

Android SDK Tools : 26.1.1
ios-deploy        : 1.9.2 
ios-sim           : 5.0.8 
Node              : v6.9.5
npm               : 4.6.1 
OS                : OS X El Capitan
Xcode             : Xcode 7.3.1 Build version 7D1014 

Environment Variables:

ANDROID_HOME : /Users/<username>/Library/Android/sdk

Misc:

backend : pro

`

Other cordova plugins used in the project:

cordova-custom-config 3.2.0 "cordova-custom-config" cordova-hot-code-push-plugin 1.5.3 "Hot Code Push Plugin" cordova-plugin-actionsheet 2.2.2 "ActionSheet" cordova-plugin-android-permissions 1.0.0 "Permissions" cordova-plugin-background-mode 0.6.5 "BackgroundMode" cordova-plugin-camera 2.4.1 "Camera" cordova-plugin-camera-preview 0.9.0 "cordova-plugin-camera-preview" cordova-plugin-compat 1.2.0 "Compat" cordova-plugin-console 1.0.3 "Console" cordova-plugin-device 1.1.7 "Device" cordova-plugin-file 4.2.0 "File" cordova-plugin-file-transfer 1.5.1 "File Transfer" cordova-plugin-geolocation 2.4.3 "Geolocation" cordova-plugin-image-picker 1.1.1 "ImagePicker" cordova-plugin-inappbrowser 1.6.1 "InAppBrowser" cordova-plugin-ionic-webview 1.2.0 "cordova-plugin-ionic-webview" cordova-plugin-media 2.3.0 "Media" cordova-plugin-network-information 1.2.1 "Network Information" cordova-plugin-request-location-accuracy 2.1.1 "Request Location Accuracy" cordova-plugin-splashscreen 3.2.2 "Splashscreen" cordova-plugin-statusbar 2.1.3 "StatusBar" cordova-plugin-vibration 2.1.1 "Vibration" cordova-plugin-whitelist 1.2.2 "Whitelist" cordova.plugins.diagnostic 3.9.2 "Diagnostic" ionic-plugin-keyboard 2.2.0 "Keyboard"

-- Thanks.

betocantu93 commented 6 years ago

@vijeth-ag Hello, did you manage to solve it? I'm getting these errors

D/CHCP: Failed to read chcp.json from assets java.io.FileNotFoundException: www/chcp.json ....

D/CHCP: Failed to convert json string into application config com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input at [Source: ; line: 1, column: 1]

...

vijeth-ag commented 6 years ago

@betocantu93 Make sure the content_url in chcp.json access url is http/https is correct based on the server. that was the case with me.