Tuesday, 21 June 2016

Cordova CLI build commands for Windows 10 and Windows Phone 8.1

By default the cordova build command produces two packages: Windows 8.1 and Windows Phone 8.1. To upgrade Windows package to version 10 the following configuration setting must be added to configuration file (config.xml).
 name="windows-target-version" value="10.0" />

Once you add this setting build command will start producing Windows 10 packages.
You may decide that you want to build a particular version of your application targeting a particular OS (for example, you might have set that you want to target Windows 10, but you want to build for Windows Phone 8.1). To do this, you can use the --appx parameter:
cordova build windows -- --appx=8.1-phone
The build system will ignore the preference set in config.xml for the target Windows version and strictly build a package for Windows Phone 8.1.
Valid values for the --appx flag are 8.1-win8.1-phone, and uap (for Windows 10 Universal Apps). These options also apply to the cordova run command.

Component requires .NET Native compilation, not available targeting Windows10, AnyCPU

I've been having more pain with Cordova for Windows phones. I updated my Cordova CLI to 6.2.0 to overcome a problem I was having in Cordova/lib/prepare.js when building. It seems to work, but then a new problem appeared - or perhaps it was the same problem but with a more friendly message:

The following component requires .NET Native compilation which is not available when targeting 'Windows10' and 'AnyCPU'. Please consider changing the targeted processor architecture to one of the following: 'x86, x64, ARM' (if you are using command line this could be done by adding '--archs' parameter, for example: 'cordo va build windows --archs=x64'). C:\PathToMyProject\platforms\windows\plugins\cordova-plugin-globalization\GlobalizationProxy.winmd Error: C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe: Command failed with exit code 1
To overcome this I had to do what it said. The following command created a successful build:

cordova build windows --archs=x86 

Implementing the Adobe DMP mobile SDKs on iOS and Android

If you're unfortunate enough to be tasked with this be prepared for it to take ten times longer than it should. You'll receive documentation that is woefully unclear, from different sources, and contradictory. When you need help you'll either not get it or wait ages for it. This has been nearly-the-worst DX I've had implementing a vendor's code, hot on the heels of ExactTarget.

But here's a tip, which I only found by rummaging through the code. Instead of silently failing, if you do this:

    [ADBMobile setDebugLogging:YES];

Then a whole new world of information will be available to you, and if you're lucky ADBMobile will actually tell you what's wrong.  This debug setting was not mentioned in any of the setup documentation I was given (there is no troubleshooting section), and neither when I sought support several times from Adobe.

Had I been told about this from the start it would have saved several people a whole lot of time.


Wednesday, 8 June 2016

Android Xamarin AddJavascriptInterface

A recent change in my codeset to API 17 caused my javascript interfaces in a webview to fail. From 17 onwards it is now a requirement that you annotate your method with [Export] and [JavascriptInterface], like so:

    [Export]
    [JavascriptInterface]
    public void Run()
    {
        //do your stuff
    }