0

After upgrading the platform and plugins to latest version and newer version app apk is not downloading and installing from existing app(versioning). Existing platform version of app is cordova 4.0.0 and latest apk platform version is 5.1.1. I followed some answer in stack but didn't solved any of them. Dont know problem with the file transfer plugin or change in platform of cordova

After debugging in adb am getting this

enter image description here

OhStack
  • 106
  • 1
  • 1
  • 15
  • @Naitik No error showing – OhStack Jul 18 '16 at 11:39
  • @Naitik versioning of app not happening after changing the latest platform(cordova 5.1.1) and latest version of plugins – OhStack Jul 18 '16 at 11:42
  • @Homen Not google play,using company server and same keystore – OhStack Jul 18 '16 at 12:00
  • @OhStack first of all latest version of cordova is 6.2.0 pleae update latest on using npm update -g cordova if you are using apple machien use sudo npm update -g cordova command then try again. Please take copy of recent one and work on that copy for avoid conflict. – Naitik Jul 18 '16 at 12:01
  • or try to directly run in real device for get good output... – Naitik Jul 18 '16 at 12:02
  • @Naitik For iOS its working fine android is the problem, by the way I tried in cordova 6.2.0 also I have multiple machine but the same result. and running in real device – OhStack Jul 18 '16 at 12:07
  • for android connect your android device with development machine and start adb service i think you aware about it. then fire command cordova run android and inspect device in chrome on chrome://inspect/#devices you will get defiantly log about your device if app at-least start. – Naitik Jul 18 '16 at 12:09
  • @Homen That thing I am trying, anything else? – OhStack Jul 18 '16 at 12:21
  • @Homen Yes incremented – OhStack Jul 18 '16 at 12:23
  • @Naitik Question edited check it now – OhStack Jul 18 '16 at 12:25
  • @OhStack : some questions.. after update cordova do you tried remove platform and add again? do you tried remove all plugins and add again ? because with your errors i can say that plugins you have installed which was supported cordova 4.0.0 and you update cordova with 5.1.1 or 6.2.0 so you need to update your all plugins and remove- add platform again and try – Naitik Jul 18 '16 at 12:27
  • The cordova.js file is placed in the www directory, so all you have to do is include that file - – Naitik Jul 18 '16 at 12:31
  • @Naitik I have created separate project after updating cordova, and added latest plugins later pasted www folder into that, cordova.js script is already there – OhStack Jul 18 '16 at 12:41
  • @OhStack As per your errortrace, looks like you dont have jquery.js file included in your project Also this error doesnt seem to have any association with failing to download latest apk – Gandhi Jul 21 '16 at 06:50
  • @ohStack do according to build.gradle file not ant – NGB Jul 21 '16 at 07:11
  • @Gandhi jquery.js included but problem started when platform version changed and plugins version changed, initially it was working fine. I think problem with file transfer plugin because this plugin use to download and upload apks – OhStack Jul 21 '16 at 07:20
  • @OhStack Could you post your project u in git so that we can test in device? – Gandhi Jul 21 '16 at 07:22
  • @gandhi I am ready to give my whole project file if you ready to solve – OhStack Jul 21 '16 at 07:23
  • @OhStack Please do so. Will give it a try. If not me, atleast someone can crack too – Gandhi Jul 21 '16 at 07:24
  • @Gandhi Uploaded project to dropbox please dont misuse the code because it is copyrighted project, please do the needful https://www.dropbox.com/s/odxfvnexcukxv23/IonTime.zip?dl=0 – OhStack Jul 22 '16 at 06:24
  • @Gandhi Did you get the file? – OhStack Jul 22 '16 at 09:22
  • @OhStack HI, dropbox is blocked in my office network. Gotta download personally – Gandhi Jul 22 '16 at 09:28
  • @OhStack Got it downloaded. Now i try should generate apk out of it with out any errors rite? – Gandhi Jul 22 '16 at 10:44
  • @OhStack Installed. On home screen got folowing alerts - IDDeviceready -> app ver:18 -> false. As per your code, you are invoking app update code only if data.appVersion is true. But its not invoking as data.appVersion is false. What is the issue here? – Gandhi Jul 22 '16 at 11:19
  • @Gandhi that is in build.gradle file it is appending 8 from that file, create gradle.properties file in platform/android location and add these contents into that cdvBuildMultipleApks=false cdvVersionCode=1 cdvMinSdkVersion=14 – OhStack Jul 26 '16 at 04:48
  • @OhStack i have replaced your gradle.properties file in my project's android platform. Let me check now – Gandhi Jul 26 '16 at 05:24
  • @OhStack i tried debugging and the error is related to coolplugin. It fails in showToast method of index.js. The error trace is as follows: index.js:148 Uncaught (in promise) ReferenceError: showToast is not defined(…) You may try out this plugin too for toast implemetation - https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin – Gandhi Jul 26 '16 at 05:45
  • @OhStack Infact i m also able to see IonTime.apk file in device's download folder too. So the download is happening but acknowledging the download using toast message seems to be the issue. Hope it helps. Can you have check on this quickly as bounty ends tomorrow :( – Gandhi Jul 26 '16 at 05:48
  • @Gandhi You mean shall I remove that coolplugin? I can directly use your plugin or something else have to do – OhStack Jul 26 '16 at 05:59
  • @OhStack If you wanna inform the user about successful download, you can use navigator.alert too instead of any plugin. The business logic decision is yours. But the code fails due to coolplugin and the way you are trying to invoke it – Gandhi Jul 26 '16 at 06:03
  • @Gandhi You only suggest me and make it work please, or tell me what should I replace to make it work – OhStack Jul 26 '16 at 06:11
  • @OhStack comment out following lines in index.js - showToast(textValue);cordova.exec(function(result){ /*alert("OK" + reply);*/ }, function(result){ /*alert("Error" + reply);*/ },"CoolPlugin",textValue,[]); Also add the following line to notify the user: "showNotification("Successfully downloaded latest version of APK", "Download Successful");" – Gandhi Jul 26 '16 at 06:21
  • @Gandhi just its showing that Notification but apk is not downloading and not installing still in first version of apk – OhStack Jul 26 '16 at 06:33
  • @Gandhi there is second version of apk in server, that should download form existing apk – OhStack Jul 26 '16 at 06:38
  • @OhStack The new version of apk is downloaded in device download folder. I dont see any code to install it. You gotta write the logic for it. May be you can use file opener plugin to open the apk which initiates the installation which obviously is out of scope of this question – Gandhi Jul 26 '16 at 06:45
  • @Gandhi Yes latest apk is downloaded, How can I install it or overwrite it with existing one – OhStack Jul 26 '16 at 07:02
  • @Gandhi initially it was taken care by coolPlugin but now I uninstalled – OhStack Jul 26 '16 at 07:03
  • @Gandhi are u there, I am about to end this.... – OhStack Jul 26 '16 at 09:07
  • @Gandhi I got this working,and want to know to how you debug this. please tell me – OhStack Jul 26 '16 at 09:48
  • @OhStack Sorry was out on meeting. You can use file opener plugin as i said earlier to prompt the user to install the same. I debugged using google chrome. Check this out - http://geeklearning.io/apache-cordova-and-remote-debugging-on-android/ Could i post the answer? – Gandhi Jul 26 '16 at 10:18
  • @NGB Hi, did you looked at the answer? The issue is resolved. Awaiting bounty :) – Gandhi Jul 26 '16 at 11:20
  • @OhStack IS NGB your colleague by any chance? If so, ask him to check out the answer – Gandhi Jul 26 '16 at 11:39
  • @Gandhi He is my senior – OhStack Jul 27 '16 at 03:42
  • @NGB Hope the answer resolved your probs. – Gandhi Jul 27 '16 at 04:26
  • @Gandhi Did you got the bounty? – OhStack Jul 27 '16 at 04:28
  • @OhStack Nope i did not :( Please do the needful – Gandhi Jul 27 '16 at 04:28
  • @OhStack Got the bounty :) Feels motivated.... – Gandhi Jul 27 '16 at 04:44
  • @Gandhi yes thanks a lot – NGB Jul 27 '16 at 04:44
  • @NGB Thanks to you too. Was a good learning experience. – Gandhi Jul 27 '16 at 04:48

1 Answers1

2

After installing the app you sent and debugging the same in Android device, i could root cause that the issue was with toast implementation in the code. It was throwing the following error in index.js :

index.js:148 Uncaught (in promise) ReferenceError: showToast is not defined(…)

I suggest you to correct the invocation of cool plugin or else use other plugin combo like toast plugin and file opener plugin to display download message & to invoke APK installation

As far the debugging is concerned, you can debug the code using google chrome's inspect devices option. You can find more info on the debugging link.

Gandhi
  • 11,875
  • 4
  • 39
  • 63