How to build a Cordova app to windows 10 (universal) - visual-studio

I'm currently developing a Cordova application with jQuery Mobile by using sublime text 3 and using Ripple to emulate my devices (I'll reference this project as SublimeProject).
I can build apps for IOS, Android and Win8. But now I need to build it for Windows 10. Apparently this doesn't work with my setup.
A colleague of mine told me to import the project in Visual Studio (I'll reference this as VSProject), add the plugins in the config.xml, copy over the files to the www folder and run it. Problem here is that it just doesn't work.
When I try to run it on Android with the Ripple - Nexus (Galaxy) emulator, it'll give me a warning like this:
I Haz CHeeseburger?!?!
PushPlugin.register
We seem to be missing some stuff :(
What is kinda cool though you can fill in the textarea to pass a json object to the callback you want to execute
Success! Fail!
But when I press Fail! the program will just work, somehow.
My console shows me the following for ripple.js:
ripple.js:37 Ripple :: Environment Warming Up (Tea. Earl Grey. Hot.)
ripple.js:51 Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
ripple.js:51 GET http://localhost:4400/config.xml 404 (Not Found)(anonymous function) # ripple.js:51module.exports.initialize # ripple.js:51_baton.pass # ripple.js:13xhr.onreadystatechange # ripple.js:39
ripple.js:37 cordova :: Initialization Finished (Make it so.)
ripple.js:37 cordova :: Native back button handler was detached.
ripple.js:41 missing exec:PushPlugin.register
ripple.js:48 PushPlugin
ripple.js:48 register
Makes sense that something is wrong with pushplugin, but can't figure out what.
Additional, when I try to run the application on Windows-AnyCPU (which my actual intent is), the application will just show me the default cordova splash screen and hang there:
So that's where I'm at. I need to figure out a way to get the app to run on Windows 10. Prefered to use Visual Studio because I know it has an option to build me an .xap file.
Updates:
Update 1
I'm tracing where the PushPlugin error comes from.
try {
pushNotification = window.plugins.pushNotification;
}
pushNotification seems to be undefined, yet in my config.xml I have the following line:
<gap:plugin name="com.phonegap.plugins.pushplugin" version="2.4.0" />
Update 2
The pushplugin doesn't seem to be relevant, because when debugging in Visual Studio, I'll find the pushNotification to be not undefined.
Currently there is nothing pointing to a good reason why I only see the splash screen instead of my application.

I had the same problem and it turned out it was due to duplicate url in the $stateProvider.

Related

Is it possible to use nativescript preview functionality with HMR?

I'm using the 'tns preview' command for debugging my app, but HMR doesn't seem to be working.
I've generated a blank vue project using the 'tns create' command and started it with the preview functionality. The application is successfully deployed to an Android device, but any code changes I make won't be applied to the device.
Is this not supported or am I doing something wrong?
I managed to get it to work by adding the following option in the webpack config file:
watchOptions: {
poll: 1000 // Check for changes every second
}
I would strongly recommend using --no-hmr option while using nativescript-vue.
Even it will watch changes, it won't show always expected behaves.
Restarting of the application just takes 3-5 seconds but saves you lots of trouble in long term.
tns preview --no-hmr or tns run --no-hmr
--no-hmr - Disables Hot Module Replacement (HMR). In this case, when a change in the code is applied, CLI will transfer the modified files and restart the application.

Windows Universal app crashes after Associating identity with Store

I'm creating a cordova app for Windows.
Now when I build this normally (with my own identity of which I have no clue where he gets it from) everything works fine and my app launches with success.
Although when I then associate my app with the Store, and have my actual app name + package name etc filled in for me, I get a blank screen when trying to run my app.
The head and body tags stay empty and no error is thrown in my JavaScript console.
Any idea of why this happens? The problem definitely is that I associate my app with the Store and then something happens which makes my app crash or fail to start.
But why does it do this? And how can I resolve it?
(currently building with VS2017)
edit
Alright, so I figured out that because the package name changed, I had to edit that as well in the manifest. Now My main root component is loaded, but it isn't setting the app root to any page, just a blank screen. (with a menu that can open on swipe).
Alright, so my Microsoft assigned package name was different than my own. This caused the app to look for my own package name instead of the Microsoft one I associated with.
The solution was quite simple, just set your widget-id in your config.xml to the Microsoft assigned package name and rebuild your solution.
(I was using Ionic framework so re-execute ionic build windows --release --prod --arch="arm")

debugger doesn't work in chrome / safari/ firefox for ember app

I am working in an ember application. The version is "ember-cli": "1.13.13".
For a very strange reason, debugger doesn't work in Chrome. (I also tried Safari, and Firefox developer's edition. Same thing.)
Specifically, the problem is I put a debugger statement in a function. Ember app loads and hits the function and the debugger statement in the function. What happens in the Developer Tools -> Sources tab is that it doesn't show me the function that the debugger is in.
Instead it keeps highlighting the last line of app-boot.js file. The breakpoint, or the line that it's paused on, is not showing up at all. (see screenshot attached)
Furthermore when I step into the function call using the down arrow, it remains at app-boot.js, so I have no idea whether it did step into the function or not.
This has been plaguing me for a while now.
I've resolved many times similar error on OSX + Chrome by using Empty Cache and Hard Reload - after that code in Sources tab was updated and I could correctly see actual source code.
Make sure you didn't blackbox scripts of your application.
Alternatively you could try to reinstall npm packages, bower packages - it might be issue with creating source maps in Ember CLI.
If nothing helps please investigate your JavaScript and associated map files and check if something might be missing, or maps don't update. You could possibly try turning them on and off in Ember CLI.
See Source Maps section in Ember CLI guides how to enable/disable them.

How to debug in VS instead of JIT Debugger?

UPDATE: navigating to the process via menu:DEBUG / Attach Process / iexplore.exe shows "Automatic: Silverlight code". i.e. VS 2010 already attached to the process. Why doesn't it go to debug view?
I have a frustrating debug behaviour going on on my laptop which I'd like to fix. I was following along with the demo called Silverlight TV 46: What's Wrong with my WCF Service?
On my computer, I noticed that putting throw new ArithmeticException() in the RIA service causes the just-in-time debugger to get involved (a bad thing -- I want VS). I can put a break point on the the throw new ArithmeticExpression() line, and VS stops as it normally does. Press F10, and I still get the just-in-time debugger kicking in.
On Yvor's computer (the presenter in the Ch 8 link above), the visual studio debugger kicks in instead of the just-in-time one. What am I doing wrong? Could having Redgate Reflector installed previously have caused this (it is gone now).
ERROR:
Visual Studio Just-In-Time Debugger
Code: 4004
Category: ManagedRuntimeError
Message: System.Reflection.TargetInvocationException: An exception occurred during the operation, making the result invalid.
Check ...
Possible Debuggers:
New instance of MS VS 2010,
New instance of VS 2008.
[checked] Set currently selected debugger as the default.
[unchecked] Manually choose the debugging engines
Action: Hit Yes.
2nd ERROR:
Unable to attach to the crashing process. A debugger is already attached.
I've spent several hours looking for a way to solve this.
Browser is IE9 / Silverlight 4.
Previously, I started starting the silverlight app directly via the VS2010 environment... but then decided to get more deployment compliant (again).
http://msdn.microsoft.com/en-us/library/cc838267(VS.95).aspx
Down the bottom they mention repairing from control panel / VS2010. Did that. Waited for ages, made coffee, did something else. Finally complete. Problem sill there. Included this step just-in-case the fix is cumulative (you get superstitious after a while with these things).
I then deleted zap files, switched startup page from html to the aspx one. Wired aspx to the xap (it wasn't pointing to the /debug/ folder). [note: looks like you can remove the debug via Silverlight Project / build / Output path: Replace Bin\Debug\ with Bin. With Silverlight I feel that the relative Uri path should match up to your html / aspx files no matter what -- wheather you are in Debug or Release.
project properties / Web / Specific Page
debugging works again!
Did .html stop debugging? Casual inspection reveals the same javascript stuff firing up Silverlight. On the surface it looks the same. hmmm. I guess it isn't.
... here are a few extra things to look at for those who still have issues (I may as well list them
while they are fresh in my mind).
project / properties / Web / Debuggers: I now only have Silverlight checked. ASP.Net is not checked any more. (Not sure if this influences my result at this stage)
make sure your web project points to the silverlight project in project / properties / Silverlight Applications. This ensures that the silverlight project's binary "xap" is copied to a folder within the Web Site / Web App. Note: hitting the add button reveals a destination folder (should be ClientBin).
Your build configuration will add an additional sub foler e.g. debug.
Make sure your .aspx or .html files have the right path. For me, I just included the .ClientBin/debug/ folder. I don't think this is deploy friendly, so I will search for a better way later.
IE9 settings.
[X] Disable script debugging.
[X] Disable script debugging (Other)
[ ] Display notification about a script error
[ ] Show friendly HTTP error message
Again, unsure if these later setting have an impact.
Lastly, there's something that I forget about sometimes. Be sure to check Debug VS2010 / Exceptions / Common language Runtime. This ups the ability to catch exceptions.
I had a similar problem, but the above did not resolve it. However, starting the application without debugging (Ctrl-F5) and triggering the exception would allow me to select the Visual Studio instance that I started the application from. Amazingly, I got a sensible stack trace and resolve the problem within a few minutes.

Another knack on the "Dialogs must be user-initiated" Security Exception in Silverlight printing

I get the infamous "Dialogs must be user-initiated" Security Exception when I try to print some stuff in Silverlight. As you can see, the dialog is as user-initiated as can be:
John Papa couldn't help me much out neither, because I don't have any breakpoint set. Mr MSDN thinks it could also be that I'm just taking too long, but this is a demo application just as simple as can be.
Any ideas? I guess it's a Visual Studio quirk, maybe some extensions interfering, as things seems to work when I launch the application outside of it. I first thought maybe the Code Contracts are interfering with their IL weaving, but they are deactivated for this project.
Update: This is just a simple Silverlight application that runs locally from the file system. When I do "Start debugging", Visual Studio creates a hosting HTML file containing the Silverlight app in the Debug resp. Release folder of the project, launches the Internet Explorer with that HTML file and attaches the debugger to it.
Update 2: I also get the same error when I create a web project to host the Silverlight app and create a virtual directory for it on IIS.
I might also want to add that I don't have problems with printing in other Silverlight projects regardless of their hosting scenarios.
Update 3: I downloaded FireFox and it works, I don't get the error when I debug with it. So it seems to have to do with my IE8. I uploaded the solution:
http://dl.dropbox.com/u/10401470/Code/Demos/PrintingDemo.zip
I wonder if anyone can reproduce?
Anyone got an idea to which team I should file a bug report? Silverlight team? IE team? VS Debugger team?
I'm able to reproduce this. You have handled the Click twice, once in XAML another time in code. See your MainPage.xaml
<Button x:Name="PrintButton"
Content="Gotta print 'em!" Margin="8"
Click="PrintButton_Click" />
Don't feel bad about it. I did it last time through a misplaced Print inside a loop.
I've also experienced this strange behaviour. A standard button click event immediately invoking an OpenFileDialog. It would frequently generate the same error when being debugged but would eventually be coaxed in to working when the button is clicked several times.
However when built as a release (or perhaps simply by running the same Xap without a debugger attached to the browser) the problem would go away.
Try to remove
if(SightPaleceListBox.Items.Count > 0)
I had the same problem and found out that the reason was this following line:
cnvsMain.Children.Remove(PrintPagePlaceHolder);
cnvMain is on the page that the user pushed the Print button on (I was trying to remove it from that page in order to add it to the canvas that I was going to print).
My tip: try to comment rows one by one, until you find what row causes the problem. Than try to work around it.

Resources