Shiny App not working on shinyapps.io but works locally

I have an error where when I run my app locally in RStudio (viewer pane or externally) it works perfectly as I want, but once deploying it I get errors and have to check the logs. This is my second app (my first one was much simpler) that I've tried making, so I have no idea what I've done wrong. I'll include the log output, and I'm using the PortfolioAnalytics package to optimise portfolios, then chart their weights, returns, and output text of annual return.

2021-06-16T19:04:20.160722+00:00 shinyapps[4281056]: Running on host: f3d412e68f6d
2021-06-16T19:04:20.166444+00:00 shinyapps[4281056]: shiny version: 1.6.0
2021-06-16T19:04:20.166403+00:00 shinyapps[4281056]: Server version: 1.8.6.1
2021-06-16T19:04:20.166413+00:00 shinyapps[4281056]: LANG: en_GB.UTF-8
2021-06-16T19:04:20.166525+00:00 shinyapps[4281056]: RJSONIO version: (none)
2021-06-16T19:04:20.166451+00:00 shinyapps[4281056]: httpuv version: 1.6.1
2021-06-16T19:04:20.166423+00:00 shinyapps[4281056]: R version: 4.0.4
2021-06-16T19:04:20.166687+00:00 shinyapps[4281056]: Using pandoc: /opt/connect/ext/pandoc/2.11
2021-06-16T19:04:20.166498+00:00 shinyapps[4281056]: rmarkdown version: (none)
2021-06-16T19:04:20.166507+00:00 shinyapps[4281056]: knitr version: (none)
2021-06-16T19:04:20.365029+00:00 shinyapps[4281056]: Using jsonlite for JSON processing
2021-06-16T19:04:20.368364+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.368365+00:00 shinyapps[4281056]: Starting R with process ID: '25'
2021-06-16T19:04:20.166507+00:00 shinyapps[4281056]: jsonlite version: 1.7.2
2021-06-16T19:04:20.166525+00:00 shinyapps[4281056]: htmltools version: 0.5.1.1
2021-06-16T19:04:20.459739+00:00 shinyapps[4281056]: Loading required package: zoo
2021-06-16T19:04:20.503599+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.503600+00:00 shinyapps[4281056]: Attaching package: ‘zoo’
2021-06-16T19:04:20.503601+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.504291+00:00 shinyapps[4281056]: The following objects are masked from ‘package:base’:
2021-06-16T19:04:20.504291+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.504292+00:00 shinyapps[4281056]:     as.Date, as.Date.numeric
2021-06-16T19:04:20.504292+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.553114+00:00 shinyapps[4281056]: Loading required package: foreach
2021-06-16T19:04:20.505294+00:00 shinyapps[4281056]: Loading required package: xts
2021-06-16T19:04:20.566521+00:00 shinyapps[4281056]: Loading required package: PerformanceAnalytics
2021-06-16T19:04:20.629293+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.629295+00:00 shinyapps[4281056]: Attaching package: ‘PerformanceAnalytics’
2021-06-16T19:04:20.629296+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.629587+00:00 shinyapps[4281056]: The following object is masked from ‘package:graphics’:
2021-06-16T19:04:20.629588+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.629589+00:00 shinyapps[4281056]:     legend
2021-06-16T19:04:20.629589+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.668116+00:00 shinyapps[4281056]: 
2021-06-16T19:04:20.668118+00:00 shinyapps[4281056]: Listening on http://127.0.0.1:46764
2021-06-16T19:04:28.434593+00:00 shinyapps[4281056]: Warning: executing %dopar% sequentially: no parallel backend registered
2021-06-16T19:04:28.741567+00:00 shinyapps[4281056]: Warning in offset + (if (log.dat) 0.9 * height else -0.01 * height) :
2021-06-16T19:04:28.741567+00:00 shinyapps[4281056]:   Recycling array of length 1 in vector-array arithmetic is deprecated.
2021-06-16T19:04:28.741569+00:00 shinyapps[4281056]:   Use c() or as.vector() instead.
2021-06-16T19:04:28.741684+00:00 shinyapps[4281056]:   Recycling array of length 1 in array-vector arithmetic is deprecated.
2021-06-16T19:04:28.789885+00:00 shinyapps[4281056]:   185: [.xts
2021-06-16T19:04:28.789884+00:00 shinyapps[4281056]:   186: stop
2021-06-16T19:04:28.789886+00:00 shinyapps[4281056]:   183: chart.StackedBar.xts
2021-06-16T19:04:28.789886+00:00 shinyapps[4281056]:   182: chart.StackedBar
2021-06-16T19:04:28.741683+00:00 shinyapps[4281056]: Warning in height + offset :
2021-06-16T19:04:28.741569+00:00 shinyapps[4281056]: 
2021-06-16T19:04:28.789899+00:00 shinyapps[4281056]:   123: <reactive:plotObj>
2021-06-16T19:04:28.789900+00:00 shinyapps[4281056]:    12: fn
2021-06-16T19:04:28.789900+00:00 shinyapps[4281056]:    93: output$WeightsPlot
2021-06-16T19:04:28.789900+00:00 shinyapps[4281056]:    13: runApp
2021-06-16T19:04:28.789901+00:00 shinyapps[4281056]:     7: connect$retry
2021-06-16T19:04:28.789901+00:00 shinyapps[4281056]:     5: eval
2021-06-16T19:04:28.789899+00:00 shinyapps[4281056]:    94: renderFunc
2021-06-16T19:04:28.773705+00:00 shinyapps[4281056]: Warning: Error in [.xts: subscript out of bounds
2021-06-16T19:04:28.789887+00:00 shinyapps[4281056]:   181: chart.Weights.optimize.portfolio.rebalancing
2021-06-16T19:04:28.789899+00:00 shinyapps[4281056]:   107: drawReactive
2021-06-16T19:04:28.789889+00:00 shinyapps[4281056]:   137: drawPlot
2021-06-16T19:04:28.741685+00:00 shinyapps[4281056]:   Use c() or as.vector() instead.
2021-06-16T19:04:28.789888+00:00 shinyapps[4281056]:   179: renderPlot [/srv/connect/apps/PortfolioUpdated/app.R#111]
2021-06-16T19:04:28.789901+00:00 shinyapps[4281056]:     6: eval
2021-06-16T19:04:28.741686+00:00 shinyapps[4281056]: 
2021-06-16T19:04:28.789888+00:00 shinyapps[4281056]:   177: func
2021-06-16T19:04:29.217064+00:00 shinyapps[4281056]: Warning: Error in UseMethod: no applicable method for 'extractObjectiveMeasures' applied to an object of class "c('simpleError', 'error', 'condition')"
2021-06-16T19:04:29.223136+00:00 shinyapps[4281056]:   186: extractObjectiveMeasures
2021-06-16T19:04:29.223138+00:00 shinyapps[4281056]:   184: extractObjectiveMeasures.optimize.portfolio.rebalancing
2021-06-16T19:04:29.223139+00:00 shinyapps[4281056]:   182: summary.optimize.portfolio.rebalancing
2021-06-16T19:04:29.223139+00:00 shinyapps[4281056]:   179: renderPlot [/srv/connect/apps/PortfolioUpdated/app.R#174]
2021-06-16T19:04:29.223140+00:00 shinyapps[4281056]:   177: func
2021-06-16T19:04:29.223141+00:00 shinyapps[4281056]:   137: drawPlot
2021-06-16T19:04:29.223141+00:00 shinyapps[4281056]:   123: <reactive:plotObj>
2021-06-16T19:04:29.223169+00:00 shinyapps[4281056]:   107: drawReactive
2021-06-16T19:04:29.223172+00:00 shinyapps[4281056]:    93: output$CompoundedCumulativeReturns
2021-06-16T19:04:29.223173+00:00 shinyapps[4281056]:    12: fn
2021-06-16T19:04:29.223170+00:00 shinyapps[4281056]:    94: renderFunc
2021-06-16T19:04:29.223172+00:00 shinyapps[4281056]:    13: runApp
2021-06-16T19:04:29.223173+00:00 shinyapps[4281056]:     7: connect$retry
2021-06-16T19:04:29.223174+00:00 shinyapps[4281056]:     6: eval
2021-06-16T19:04:29.223174+00:00 shinyapps[4281056]:     5: eval
2021-06-16T19:04:29.466805+00:00 shinyapps[4281056]:   114: extractObjectiveMeasures
2021-06-16T19:04:29.462447+00:00 shinyapps[4281056]: Warning: Error in UseMethod: no applicable method for 'extractObjectiveMeasures' applied to an object of class "c('simpleError', 'error', 'condition')"
2021-06-16T19:04:29.466805+00:00 shinyapps[4281056]:   112: extractObjectiveMeasures.optimize.portfolio.rebalancing
2021-06-16T19:04:29.466806+00:00 shinyapps[4281056]:   110: summary.optimize.portfolio.rebalancing
2021-06-16T19:04:29.466807+00:00 shinyapps[4281056]:   108: renderText [/srv/connect/apps/PortfolioUpdated/app.R#238]
2021-06-16T19:04:29.466807+00:00 shinyapps[4281056]:   107: func
2021-06-16T19:04:29.466808+00:00 shinyapps[4281056]:    94: renderFunc
2021-06-16T19:04:29.466831+00:00 shinyapps[4281056]:    13: runApp
2021-06-16T19:04:29.466829+00:00 shinyapps[4281056]:    93: output$AnnualizedReturn
2021-06-16T19:04:29.466832+00:00 shinyapps[4281056]:    12: fn
2021-06-16T19:04:29.466833+00:00 shinyapps[4281056]:     6: eval
2021-06-16T19:04:29.466832+00:00 shinyapps[4281056]:     7: connect$retry
2021-06-16T19:04:29.466833+00:00 shinyapps[4281056]:     5: eval
2021-06-16T19:05:07.023471+00:00 shinyapps[4281056]: Warning in offset + (if (log.dat) 0.9 * height else -0.01 * height) :
2021-06-16T19:05:07.023473+00:00 shinyapps[4281056]:   Recycling array of length 1 in vector-array arithmetic is deprecated.
2021-06-16T19:05:07.023474+00:00 shinyapps[4281056]:   Use c() or as.vector() instead.
2021-06-16T19:05:07.023475+00:00 shinyapps[4281056]: 
2021-06-16T19:05:07.023586+00:00 shinyapps[4281056]:   Recycling array of length 1 in array-vector arithmetic is deprecated.
2021-06-16T19:05:07.023588+00:00 shinyapps[4281056]: 
2021-06-16T19:05:07.057488+00:00 shinyapps[4281056]:   177: func
2021-06-16T19:05:07.023587+00:00 shinyapps[4281056]:   Use c() or as.vector() instead.
2021-06-16T19:05:07.051100+00:00 shinyapps[4281056]: Warning: Error in [.xts: subscript out of bounds
2021-06-16T19:05:07.057485+00:00 shinyapps[4281056]:   185: [.xts
2021-06-16T19:05:07.023585+00:00 shinyapps[4281056]: Warning in height + offset :
2021-06-16T19:05:07.057484+00:00 shinyapps[4281056]:   186: stop
2021-06-16T19:05:07.057513+00:00 shinyapps[4281056]:   137: drawPlot
2021-06-16T19:05:07.057515+00:00 shinyapps[4281056]:    94: renderFunc
2021-06-16T19:05:07.057487+00:00 shinyapps[4281056]:   181: chart.Weights.optimize.portfolio.rebalancing
2021-06-16T19:05:07.057488+00:00 shinyapps[4281056]:   179: renderPlot [/srv/connect/apps/PortfolioUpdated/app.R#111]
2021-06-16T19:05:07.057514+00:00 shinyapps[4281056]:   123: <reactive:plotObj>
2021-06-16T19:05:07.057515+00:00 shinyapps[4281056]:   107: drawReactive
2021-06-16T19:05:07.057516+00:00 shinyapps[4281056]:    93: output$WeightsPlot
2021-06-16T19:05:07.057517+00:00 shinyapps[4281056]:    12: fn
2021-06-16T19:05:07.057486+00:00 shinyapps[4281056]:   183: chart.StackedBar.xts
2021-06-16T19:05:07.057486+00:00 shinyapps[4281056]:   182: chart.StackedBar
2021-06-16T19:05:07.057516+00:00 shinyapps[4281056]:    13: runApp
2021-06-16T19:05:07.057517+00:00 shinyapps[4281056]:     7: connect$retry
2021-06-16T19:05:07.057517+00:00 shinyapps[4281056]:     6: eval
2021-06-16T19:05:07.057518+00:00 shinyapps[4281056]:     5: eval
2021-06-16T19:05:07.399484+00:00 shinyapps[4281056]: Warning: Error in UseMethod: no applicable method for 'extractObjectiveMeasures' applied to an object of class "c('simpleError', 'error', 'condition')"
2021-06-16T19:05:07.405631+00:00 shinyapps[4281056]:   186: extractObjectiveMeasures
2021-06-16T19:05:07.405632+00:00 shinyapps[4281056]:   184: extractObjectiveMeasures.optimize.portfolio.rebalancing
2021-06-16T19:05:07.405633+00:00 shinyapps[4281056]:   182: summary.optimize.portfolio.rebalancing
2021-06-16T19:05:07.405654+00:00 shinyapps[4281056]:   177: func
2021-06-16T19:05:07.405634+00:00 shinyapps[4281056]:   179: renderPlot [/srv/connect/apps/PortfolioUpdated/app.R#174]
2021-06-16T19:05:07.405654+00:00 shinyapps[4281056]:   137: drawPlot
2021-06-16T19:05:07.405658+00:00 shinyapps[4281056]:   123: <reactive:plotObj>
2021-06-16T19:05:07.405667+00:00 shinyapps[4281056]:    93: output$CompoundedCumulativeReturns
2021-06-16T19:05:07.405668+00:00 shinyapps[4281056]:    13: runApp
2021-06-16T19:05:07.405668+00:00 shinyapps[4281056]:    12: fn
2021-06-16T19:05:07.405667+00:00 shinyapps[4281056]:    94: renderFunc
2021-06-16T19:05:07.405667+00:00 shinyapps[4281056]:   107: drawReactive
2021-06-16T19:05:07.405668+00:00 shinyapps[4281056]:     6: eval
2021-06-16T19:05:07.405668+00:00 shinyapps[4281056]:     7: connect$retry
2021-06-16T19:05:07.405669+00:00 shinyapps[4281056]:     5: eval
2021-06-16T19:05:07.645472+00:00 shinyapps[4281056]: Warning: Error in UseMethod: no applicable method for 'extractObjectiveMeasures' applied to an object of class "c('simpleError', 'error', 'condition')"
2021-06-16T19:05:07.649877+00:00 shinyapps[4281056]:   114: extractObjectiveMeasures
2021-06-16T19:05:07.649878+00:00 shinyapps[4281056]:   112: extractObjectiveMeasures.optimize.portfolio.rebalancing
2021-06-16T19:05:07.649878+00:00 shinyapps[4281056]:   110: summary.optimize.portfolio.rebalancing
2021-06-16T19:05:07.649879+00:00 shinyapps[4281056]:   108: renderText [/srv/connect/apps/PortfolioUpdated/app.R#238]
2021-06-16T19:05:07.649879+00:00 shinyapps[4281056]:   107: func
2021-06-16T19:05:07.649880+00:00 shinyapps[4281056]:    94: renderFunc
2021-06-16T19:05:07.649880+00:00 shinyapps[4281056]:    93: output$AnnualizedReturn
2021-06-16T19:05:07.649880+00:00 shinyapps[4281056]:    13: runApp
2021-06-16T19:05:07.649902+00:00 shinyapps[4281056]:    12: fn
2021-06-16T19:05:07.649903+00:00 shinyapps[4281056]:     7: connect$retry
2021-06-16T19:05:07.649903+00:00 shinyapps[4281056]:     6: eval
2021-06-16T19:05:07.649904+00:00 shinyapps[4281056]:     5: eval

Edit: Solved, check my bottom reply

I would start from basics.
Make a more trivial app that just loads your libraries, and maybe shows a text output.
you could make it show you sessionInfo for example
then compare this to your working app which relies on the same libraries.
After that you could maybe try iteratively adding in parts of your app, though this may be somewhat arduous for you. On the other foot you might add print or cat or logger statements to print to console (i.e. shiny log) when you enter a function (reactive or otherwise) and leave it. My apps often has these as they can help alot if stacktraces are confusing/absent. (as can be the case in tidyverse ).
From the logs, I think output$WeightsPlot may be a culprit. But theres little to go on

good luck.

I am having a similar problem where my app works in Rstudio but fails to deploy. Thanks for any assistance:

2021-06-17T15:03:06.458156+00:00 shinyapps[1318387]: Warning: Error in lapply: invalid multibyte string at '<a0>'
2021-06-17T15:03:06.462078+00:00 shinyapps[1318387]:   61: st_as_sf.data.frame
2021-06-17T15:03:06.462077+00:00 shinyapps[1318387]:   63: lapply
2021-06-17T15:03:06.462079+00:00 shinyapps[1318387]:   56: <observer> [/srv/connect/apps/CameraApp/server.R#119]
2021-06-17T15:03:06.462080+00:00 shinyapps[1318387]:   13: runApp
2021-06-17T15:03:06.462080+00:00 shinyapps[1318387]:   12: fn
2021-06-17T15:03:06.462081+00:00 shinyapps[1318387]:    7: connect$retry
2021-06-17T15:03:06.462081+00:00 shinyapps[1318387]:    6: eval
2021-06-17T15:03:06.462081+00:00 shinyapps[1318387]:    5: eval

Your issue seems to be a matter of the text encoding of your script, or some textual data you load.

I fixed the issue, it seemed that Shiny was publishing using a different version of some of the packages that messed with some elements of functionality in the "optimize.portfolio.rebalancing" causing it to default to outputting an error as a column vector (hence why none of the code afterwards, namely the plot and render text worked).