Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Not functioning correctly when build using Phonegap build #118

Closed
ghost opened this issue Mar 11, 2016 · 15 comments
Closed

Not functioning correctly when build using Phonegap build #118

ghost opened this issue Mar 11, 2016 · 15 comments

Comments

@ghost
Copy link

ghost commented Mar 11, 2016

When I build the app using cordova on my system, the app works as intended. But when I build the same app using Phonegap build, then it doesn't check for any update.
After debugging the app, I found this error in the logs

03-10 18:45:36.183: W/System.err(12358): java.net.MalformedURLException: Protocol not found: 
03-10 18:45:36.183: W/System.err(12358):    at java.net.URL.<init>(URL.java:176)
03-10 18:45:36.183: W/System.err(12358):    at java.net.URL.<init>(URL.java:125)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.utils.URLUtility.stringToUrl(URLUtility.java:27)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.network.JsonDownloader.downloadJson(JsonDownloader.java:65)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.network.JsonDownloader.download(JsonDownloader.java:49)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.download(ApplicationConfigDownloader.java:13)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.downloadApplicationConfig(UpdateLoaderWorker.java:165)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.run(UpdateLoaderWorker.java:75)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.updater.UpdatesLoader$1.run(UpdatesLoader.java:61)
03-10 18:45:36.184: W/System.err(12358):    at java.lang.Thread.run(Thread.java:818)
03-10 18:45:36.184: W/System.err(12358): java.lang.Exception: Invalid url format:
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.network.JsonDownloader.downloadJson(JsonDownloader.java:67)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.network.JsonDownloader.download(JsonDownloader.java:49)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.download(ApplicationConfigDownloader.java:13)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.downloadApplicationConfig(UpdateLoaderWorker.java:165)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.run(UpdateLoaderWorker.java:75)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.updater.UpdatesLoader$1.run(UpdatesLoader.java:61)
03-10 18:45:36.184: W/System.err(12358):    at java.lang.Thread.run(Thread.java:818)
03-10 18:45:36.184: D/CHCP(12358): Failed to download application config
03-10 18:45:36.184: D/CHCP(12358): Failed to update

But on cordova build the same is working and the update is checked.

Since we have to automate our process for the mobile apps, we are using Phonegap build service. So, could you please guide me, what could be the issue, if I am doing something wrong.
It would be a great help.

@ghost
Copy link
Author

ghost commented Mar 11, 2016

After some findings, I found out that Phonegap doesn't support cordova hooks and the plugin has some hooks that are executed when build using cordova. So, is there any way that I could make phonegap to do the tasks from the hooks, or if you could tell me what the hook does so that i could try some options.

@nikDemyankov
Copy link
Member

Yes, PGB build doesn't support hooks. You are not the first one, who stumble upon that. I really need to add that in the readme file...

Since you are building for Android - hooks are not needed. They are used only for chcpbuild.options. According to the log - something is wrong with the chcp.json file url: either it is empty, or has a wrong format. Please, check that config.xml of your Cordova project contains correct config-file preference. For example:

<chcp>
  <config-file url="http://mydomain.com/some/path/chcp.json" />
</chcp>

@ghost
Copy link
Author

ghost commented Mar 14, 2016

Hi nikDemyankov,

The config.xml file for my app is

<?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.satpal" versionCode="100"
        version="1.0.0">
    <name>Satpal 2</name>
    <description>TEst CHcp json</description>
    <author email="tanansatpal@gmail.com" href="http://cordova.io">Satpal Tanan</author>
    <content src="index.html"/>
    <access origin="*"/>
    <gap:config-file platform="ios" parent="CFBundleShortVersionString">
        <string>100</string>
    </gap:config-file>
    <chcp>
        <config-file
                url="http://s3.amazonaws.com/mystore.in/s/53ca09a468dbb34762b98894/ms.mobile_app_themes/56e17107e0339962486bd739/chcp.json"/>
    </chcp>
    <gap:platform name="android"/>
    <gap:platform name="ios"/>
    <platform name="android">
        <splash src="splash/android/ldpi.png" gap:platform="android" gap:density="ldpi"/>
        <splash src="splash/android/mdpi.png" gap:platform="android" gap:density="mdpi"/>
        <splash src="splash/android/hdpi.png" gap:platform="android" gap:density="hdpi"/>
        <splash src="splash/android/xhdpi.png" gap:platform="android" gap:density="xhdpi"/>
        <icon src="icons/android/ldpi.png" gap:platform="android" gap:density="ldpi"/>
        <icon src="icons/android/mdpi.png" gap:platform="android" gap:density="mdpi"/>
        <icon src="icons/android/hdpi.png" gap:platform="android" gap:density="hdpi"/>
        <icon src="icons/android/xhdpi.png" gap:platform="android" gap:density="xhdpi"/>
        <icon src="icons/android/xxhdpi.png" gap:platform="android" gap:density="xxhdpi"/>
        <icon src="icons/android/xxxhdpi.png" gap:platform="android" gap:density="xxxhdpi"/>
    </platform>
    <platform name="ios">
        <splash src="splash/ios/Default~iphone.png" gap:platform="ios" width="320" height="480"/>
        <splash src="splash/ios/Default@2x~iphone.png" gap:platform="ios" width="640" height="960"/>
        <splash src="splash/ios/Default-Portrait~ipad.png" gap:platform="ios" width="768" height="1024"/>
        <splash src="splash/ios/Default-Portrait@2x~ipad.png" gap:platform="ios" width="1536" height="2048"/>
        <splash src="splash/ios/Default-Landscape~ipad.png" gap:platform="ios" width="1024" height="768"/>
        <splash src="splash/ios/Default-Landscape@2x~ipad.png" gap:platform="ios" width="2048" height="1536"/>
        <splash src="splash/ios/Default-Landscape-736h.png" gap:platform="ios" width="2208" height="1242"/>
        <splash src="splash/ios/Default-736h.png" gap:platform="ios" width="1242" height="2208"/>
        <splash src="splash/ios/Default-667h.png" gap:platform="ios" width="750" height="1334"/>
        <splash src="splash/ios/Default-568h@2x~iphone.png" gap:platform="ios" width="640" height="1136"/>
        <icon src="icons/ios/icon.png" gap:platform="ios" width="57" height="57"/>
        <icon src="icons/ios/icon-40.png" gap:platform="ios" width="40" height="40"/>
        <icon src="icons/ios/icon-72.png" gap:platform="ios" width="72" height="72"/>
        <icon src="icons/ios/icon-72@2x.png" gap:platform="ios" width="144" height="144"/>
        <icon src="icons/ios/icon-76.png" gap:platform="ios" width="76" height="76"/>
        <icon src="icons/ios/icon@2x.png" gap:platform="ios" width="114" height="114"/>
        <icon src="icons/ios/icon-60.png" gap:platform="ios" width="60" height="60"/>
        <icon src="icons/ios/icon-60@2x.png" gap:platform="ios" width="120" height="120"/>
        <icon src="icons/ios/icon-60@3x.png" gap:platform="ios" width="180" height="180"/>
        <icon src="icons/ios/icon-76@2x.png" gap:platform="ios" width="152" height="152"/>
        <icon src="icons/ios/icon-40@2x.png" gap:platform="ios" width="80" height="80"/>
        <icon src="icons/ios/icon-small.png" gap:platform="ios" width="29" height="29"/>
        <icon src="icons/ios/icon-small@2x.png" gap:platform="ios" width="58" height="58"/>
        <icon src="icons/ios/icon-50.png" gap:platform="ios" width="50" height="50"/>
        <icon src="icons/ios/icon-50@2x.png" gap:platform="ios" width="100" height="100"/>
    </platform>
    <preference name="permissions" value="none"/>
    <preference name="orientation" value="default"/>
    <preference name="android-windowSoftInputMode" value="adjustResize"/>
    <preference name="fullscreen" value="false"/>
    <preference name="webviewbounce" value="true"/>
    <preference name="android-minSdkVersion" value="14"/>
    <preference name="KeepRunning" value="false"/>
    <preference name="LoadUrlTimeoutValue" value="10000"/>
    <preference name="android-installLocation" value="auto"/>
    <preference name="AutoHideSplashScreen" value="true"/>
    <preference name="SplashScreenDelay" value="3000"/>
    <preference name="DisallowOverscroll" value="true"/>
    <preference name="StatusBarOverlaysWebView" value="false"/>
    <preference name="StatusBarBackgroundColor" value="#000000"/>
    <preference name="StatusBarStyle" value="lightcontent"/>
    <preference name="android-build-tool" value="gradle"/>
    <plugin name="cordova-hot-code-push-plugin" spec="1.2.5"/>
    <plugin name="cordova-plugin-whitelist" spec="1.0.0"/>
    <plugin name="cordova-plugin-file" spec="3.0.0"/>
    <plugin name="cordova-plugin-file-transfer" spec="1.4.0"/>
    <plugin name="cordova-plugin-device" spec="1.1.0"/>
    <plugin name="phonegap-plugin-push" spec="1.5.3"/>
    <plugin name="cordova-plugin-statusbar" spec="2.0.0"/>
    <plugin name="cordova-plugin-inappbrowser" spec="1.1.0"/>
    <plugin name="cordova-plugin-dialogs" spec="1.2.0"/>
    <plugin name="cordova.plugins.diagnostic" spec="2.2.4"/>
    <plugin name="cordova-plugin-x-toast" spec="2.2.3"/>
    <plugin name="cordova-plugin-network-information" spec="1.1.0"/>
    <plugin name="cordova-plugin-splashscreen" spec="3.0.0"/>
</widget>

You can try the config-file url, it is correct and the content of the file is

{
  "content_url": "http://s3.amazonaws.com/mystore.in/s/53ca09a468dbb34762b98894/ms.mobile_app_themes/56e17107e0339962486bd739/",
  "release": "2016-03-11T13:05:49.084Z",
  "min_native_interface": 14,
  "update": "start",
  "android_identifier": "com.satpal",
  "ios_identifier": ""
}

So, can you please help me in identify the issue here, as I am stuck here.

@nikDemyankov
Copy link
Member

I can reproduce original question java.net.MalformedURLException by removing protocol of the config-file url like this:

<chcp>
  <config-file url="s3.amazonaws.com/mystore.in/s/53ca09a468dbb34762b98894/ms.mobile_app_themes/56e17107e0339962486bd739/chcp.json" />
</chcp>

As a result - I get that exception, since URL has no protocol => malformed. In the log you provided there is no info on the protocol he is complaining about. For example:

03-14 05:05:02.225 18575-18635/io.cordova.hellocordova W/System.err: java.net.MalformedURLException: Protocol not found: s3.amazonaws.com/mystore.in/s/53ca09a468dbb34762b98894/ms.mobile_app_themes/56e17107e0339962486bd739/chcp.json

Probably you removed it from the log. Nonetheless, check, what is displayed in there.

Also, I've tried to setup a test application with the config.xml you gave. All urls seems to be fine, so I am confused why you are getting this malformed exception... Maybe PGB get's some wrong version of the config.xml?

The only problem I got with it, is that md5 hash of the index.html on the server doesn't match md5 hash in the server's chcp.manifest. But this get's me another error, which has nothing to do with the wrong urls:

03-14 05:17:58.221 28256-28318/io.cordova.hellocordova D/CHCP: Loading file: http://s3.amazonaws.com/mystore.in/s/53ca09a468dbb34762b98894/ms.mobile_app_themes/56e17107e0339962486bd739/index.html
03-14 05:17:58.537 28256-28318/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.network.FileDownloader.download(FileDownloader.java:91)
03-14 05:17:58.537 28256-28318/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.network.FileDownloader.downloadFiles(FileDownloader.java:46)
03-14 05:17:58.537 28256-28318/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.downloadNewAndChangedFiles(UpdateLoaderWorker.java:226)
03-14 05:17:58.537 28256-28318/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.run(UpdateLoaderWorker.java:116)
03-14 05:17:58.537 28256-28318/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.updater.UpdatesLoader$1.run(UpdatesLoader.java:61)
03-14 05:17:58.541 28256-28318/io.cordova.hellocordova D/CHCP: Failed to update

@ghost
Copy link
Author

ghost commented Mar 14, 2016

Hi @nikDemyankov,
there is a second error in the log that I provided

java.lang.Exception: Invalid url format:
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.network.JsonDownloader.downloadJson(JsonDownloader.java:67)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.network.JsonDownloader.download(JsonDownloader.java:49)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.download(ApplicationConfigDownloader.java:13)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.downloadApplicationConfig(UpdateLoaderWorker.java:165)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.run(UpdateLoaderWorker.java:75)
03-10 18:45:36.184: W/System.err(12358):    at com.nordnetab.chcp.main.updater.UpdatesLoader$1.run(UpdatesLoader.java:61)
03-10 18:45:36.184: W/System.err(12358):    at java.lang.Thread.run(Thread.java:818)

its like phonegap did't read my chcp tag or the url which I provided in it.

Did you try to build the app using Phonegap because it works with local cordova build, and the update is checked correctly by chcp plugin.
But the issue is when, it is build using phonegap.

@nikDemyankov
Copy link
Member

Hi :)

Did you try to build the app using Phonegap

No, I don't have a PGB access, so I did a local testing... Just wanted to reproduce somehow this issue, and managed by defining wrong url format.

there is a second error in the log that I provided

The second error comes as a result of the first one.

its like phonegap did't read my chcp tag or the url which I provided in it.

This preference is read by the plugin, not by PGB. If it's empty - you get one error:

03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.utils.URLUtility.stringToUrl(URLUtility.java:27)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.network.JsonDownloader.downloadJson(JsonDownloader.java:71)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.network.JsonDownloader.download(JsonDownloader.java:55)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.download(ApplicationConfigDownloader.java:13)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.downloadApplicationConfig(UpdateLoaderWorker.java:163)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.run(UpdateLoaderWorker.java:73)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.updater.UpdatesLoader$1.run(UpdatesLoader.java:60)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.network.JsonDownloader.downloadJson(JsonDownloader.java:73)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.network.JsonDownloader.download(JsonDownloader.java:55)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.network.ApplicationConfigDownloader.download(ApplicationConfigDownloader.java:13)
03-14 12:01:29.809 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.downloadApplicationConfig(UpdateLoaderWorker.java:163)
03-14 12:01:29.813 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.updater.UpdateLoaderWorker.run(UpdateLoaderWorker.java:73)
03-14 12:01:29.813 20537-20586/io.cordova.hellocordova W/System.err:     at com.nordnetab.chcp.main.updater.UpdatesLoader$1.run(UpdatesLoader.java:60)

There is no Malformed exception. So my guess that it's not empty, but either modified by PGB, or you are uploading the wrong version on their server... But I might be wrong here.

Can you somehow look into Android native project before it is compiled into .apk? There should be a config.xml, packed in it - maybe PGB really stripping away unknown tags.

Or you can take .apk file, change it's extension to .zip and unzip it. Then, find config.xml and look in it for your url.

@ghost
Copy link
Author

ghost commented Mar 15, 2016

Hi @nikDemyankov ,

I checked the config.xml file before compilation version of both the cordova build and phonegap build.
The chcp tag was not there in the phonegap version but was available in the cordova tag.
Maybe PGB is really stripping the tag, is there some other way I could make it work.

@nikDemyankov
Copy link
Member

So, it was in config.xml before the prepare stage, but gone after it? That's strange... I see two ways to go:

  1. Contact PGB support about this.
  2. Fork this repo and hardcode your config-file url in ChcpXmlConfig.getConfigUrl(): method should always return your url. Then in the config.xml change plugin name to your git repo.

@szh
Copy link

szh commented Aug 11, 2016

I contacted PGB about this, and here's what they said:

phonegap/build#541 (comment)

This is expected behaviour. The config.xml file follows a spec, and tools (like build) won't support arbitrary elements.

The proper configuration for this would be for the cordova-hot-code-push plugin to support parameters for those configurations, and you would then declare it something like this:

<plugin name="cordova-hot-code-push-plugin" spec="~1.4" source="npm">
    <param name="config-file-url" value="http://example.com/mobile_repo/chcp.json" />
    <param name="native-interface-version" value="1" />
</plugin>

For a plugin that demonstrates this, have a look at the PhoneGap Push Plugin.

@szh
Copy link

szh commented Aug 16, 2016

Are there any plans to fix this by using parameters?

@nikDemyankov
Copy link
Member

@szh There is a plan to remove xml preferences and move them to chcp.json file: #161 (comment)

@JhonnyJason
Copy link

Hi there!
First of all, thanks for the plugin!

second, wanted to ask the status quo of the newly thought configuration style?

or is:
"Fork this repo and hardcode your config-file url in ChcpXmlConfig.getConfigUrl(): method should always return your url. Then in the config.xml change plugin name to your git repo."
the way to go for the moment?

cheers!

@nikDemyankov
Copy link
Member

nikDemyankov commented Jan 17, 2017

Hi @JhonnyJason ,

at the moment you can either "hardcode url", or use JS API to configure the url. I think API approach is better.

@JhonnyJason
Copy link

Ah for some unknown reason I completely neglected the JS API approach.
It indeed is a solution :-) thanx!

@nordnet-deprecation-bot
Copy link
Contributor

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

😢 We are not using nordnet/cordova-hot-code-push 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 #371 for more information.

@nordnet nordnet locked and limited conversation to collaborators Sep 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants