-
Notifications
You must be signed in to change notification settings - Fork 409
Working with UWP
UWP Apps may distributed in 2 different ways:
-
In the Windows App Store. (This should be used for deployment of any production app).
-
Outside of the Windows App Store via sideloading directly onto a device. This should only be used for development.
UWP apps may be deployed directly to Windows 10 desktop and mobile devices without any need to involve the Windows Store. This process is only realistic, though, for testing and debugging your app during development because it requires you to enable "Development" mode on the device. In addition, installation is a little bit more complicated than simply downloading an app over the internet. The process for deploying to Windows 10 desktop devices is different than the process for mobile devices. These are described in the following sections.
Before you can side-load apps onto your phone, you’ll need to set up your phone for development.
-
In "Settings", select "Update & Security" > "For developers"
-
Select "Developer mode"
-
Under "Device Discovery", make sure that the "Make your device visible to USB connections and your local network" is set to "On".
-
Make sure that "Device Portal" is set to "On"
-
When you switch "Device Portal" to "On" it should show you an address that you can access the Phone at via wifi. (E.g. https://10.0.1.11). Remember this address, you’re going to use it to install all of your apps onto the device.
NoteThis will be a local address within your local network. It won’t be available to the outside world.
At this point, your phone should be ready to receive "Side-loaded" apps. This was a one-time setup, so you shouldn’t have to do it again, until you set up another device.
Now that your device is set up for development, you can proceed to build your app.
-
Select the "Mobile Debug Build" option in the UWP Codename One Settings.
-
Select the "Send Windows UWP Build" option in the Codename One menu of your IDE. This will initiate the build on the Codename One build server.
-
Log into the Codename One dashboard to watch the build progress. When it is complete, you’ll be able to download the ".appxbundle" file to your desktop.
WarningYou cannot simply download the .appxbundle file directly to your Windows Phone 10 mobile device and install it. It will indeed allow you to download it, and will give you an option to install it, but the install will silently fail.
-
Point your computer’s web browser to the address for your mobile device. (This is the address listed when you turned on the "Device Portal" in the "Enabling Developer Mode on Device" section above. This will open the App Manager page.
-
Click on the "Apps" item in the left menu.
-
Under the "Install App" section, click the "Choose File" button and navigate through the file chooser to select the .appxbundle file for your app. If this is the first time installing an app on your device, you may also need to provide the dependencies. (You can find the dependencies for mobile/ARM apps here. You’ll need to provide both
Microsoft.NET.CoreRuntime.1.0.appx
andMicrosoft.VCLibs.ARM.Debug.14.00.appx
). Click the "Add Dependency" button, and use the file chooser to select both of the .appx dependencies. Again, The dependencies will only be required the first time you install an app this way -
Once you have the appxbundle and its dependencies selected, you should press "Go" under the "Deploy" subheading. This will install the app and, if all went well, your app will appear in the "Recently Added" section in the apps list of the phone.
The easiest way to be able to run your development apps on a Windows 10 PC is to enable developer mode. This will allow you to install any app even if it is just "self-signed".
To enable developer mode, open "Settings", then select "Updates an Security". Under the "For Developers" menu item, select "Developer Mode" as shown below:
Before building the app, you’ll need to ensure that the build target is set to "Debug Desktop" in the Codename One Settings panel for Windows apps.
Steps:
-
Open Codename One Settings (steps vary by IDE). On Netbeans you will find "Codename One Settings" by right clicking your project’s node in the project explorer, and look in the "Codename One" submenu:
-
Click on "Windows Settings":
-
Under "Build Type", make sure that "Desktop Debug Build" is selected, as shown below:
-
Save the changes by clicking the "Disk" icon in the upper right:
Now you can proceed to send the build to the build server.
-
Select the "Send Windows UWP Build" option in the Codename One menu of your IDE. This will initiate the build on the Codename One build server.
-
Log into the Codename One dashboard to watch the build progress. When it is complete, you’ll be able to download the ".zip" file to the Windows 10 PC on which you wish to install the app.
Start by extracting the .zip file. (Navigate to the folder where the zip was downloaded, right click it, and select "Extract all" as shown below:
After extraction, open the resulting directory. You should see contents similar to the following:
Downloading Dependencies
If this is your first time installing a UWP app on this PC, you may need to add the dependencies before you can install. You can download the dependencies here. Extract "Dependencies.zip" and copy the resulting "Dependencies" directory into the app install directory. Your app install directory should now look like:
Running the Powershell Script
We are finally at the point where we can run the installer.
Right-click on the "Add-AppDevPackage" icon, and select "Run in Powershell", as shown:
You may be prompted that you need to change the execution policy, in Powershell:
Enter "Y" at the prompt to allow this.
If all goes well, you should see a message saying that the app as successfully installed.
And if you look in your "Windows Menu" under "All Apps", you should see your app listed there:
If you want to be able to distribute your app to the public, the Windows Store is your best channel. Building for the Windows store involves roughly 3 steps:
-
Reserve a name for your app in the Windows Store
-
Build your app using the "Windows Store Upload" build type.
-
Upload the resulting .appxupload file to the Windows store.
Let’s go through these steps in more detail. Start here.
If you don’t already have an account, sign up for one. Then log in. Once logged in, you can click the "Dashboard" link on the toolbar.
Under the "Your apps" section (on the left in the above screenshot), click the "Create new app" button.
Enter a name for your app, and click "Reserve app name".
If the name was available, it should take you to the app overview page for your new app. There’s quite a few options there to play with, but we’re not going to worry about any of them for now. All we need to know is:
-
Your App’s ID
-
Your App’s Publisher ID
You can get this information by scrolling down to the bottom of the "App overview" page and clicking the "View app identity details" under the "App Management" > "App identity" section:
You’ll see a page with the information we need shown below:
The next step is to copy this information into your Codename One project.
Open up the Codename One Settings for your project and go to the "Windows Settings" section.
Copy and paste the "Package/Identity/Name" value from the windows store into the "App ID" field.
Next, click on the "Generate" button next to the Certificate field.
This will open a dialog titled "Certificate Generator". Paste the value from the "Package/Identity/Publisher" listed in the Windows Store into the Publisher ID field as shown below:
Then click OK. This will generate a .pfx file inside your project folder.
Finally, make sure that "Windows Store Upload" is selected in the "Build Type" field:
When you are done, hit the "Save" icon in the upper right corder of the window to save your changes.
Finally, select "Codename One" > "Send Windows UWP Build" in your IDE’s project explorer.
About This Guide
Introduction
Basics: Themes, Styles, Components & Layouts
Theme Basics
Advanced Theming
Working With The GUI Builder
The Components Of Codename One
Using ComponentSelector
Animations & Transitions
The EDT - Event Dispatch Thread
Monetization
Graphics, Drawing, Images & Fonts
Events
File-System,-Storage,-Network-&-Parsing
Miscellaneous Features
Performance, Size & Debugging
Advanced Topics/Under The Hood
Signing, Certificates & Provisioning
Appendix: Working With iOS
Appendix: Working with Mac OS X
Appendix: Working With Javascript
Appendix: Working With UWP
Security
cn1libs
Appendix: Casual Game Programming