2016/12/17

It's that time again (code signing certificates)

As I said in a previous, post code signing annoys me these years like as networks did many years ago. I've just had to renew my Comodo code signing certificate, and as usual K-Software (a Comodo reseller) made it as painless as possible. 

The process has not changed, but the graphical interface of Firefox has. So for my own future self and for others in my position now here's how it is done.

Once you have ordered the certificate from K-Software, and they have worked their magic in the case of any hiccups with Comodo, your'll get an email from Comodo, something like this:


Click on the link in the email and  the next thing you'll see is a web page on the Comodo site which asks you to enter your collection code. If all has worked well the collection code will appear in the web page automatically:


Click on the Collect Certificate button and the next screen you see should be like this:





The phrase about backing up the private key is a bit misleading if you intend to use the certificate to digitally sign your executable file. "Backing up" the certificate actually creates the file you'll use to do the code signing. So it is not really just a backup, it is central to the reason I bought the certificate.

You can see the certificate you have just collected by doing this (in FireFox):



And then selecting the certificate you want to view as shown below. Note that you can assure yourself that it is a SHA256 certificate by going into the details tab, also shown below.


 Remember that you save the pfx/p12 file by "backing it up" as shown below:
So if you've managed to save the file you can now use it to sign your executable programs.

And it does not guarantee anything to the person downloading your file, it only gets rid of the big red warning message when they download it. But that warning message could mean a lost sale...








2016/12/15

Xamarin: Finally compiled a C# program and ran it on an emulator

After about 20 hours of downloading Xamarin and Android SDKs (see here) I finally got VS2015 (apparently) able to compile C# code into an Android program. Remember that the native language of Android is Java, so Xamarin cleverly converts from C# to Java. Anyway the download and install carried on apparently without errors and with a condesceding message from the programmer in the dialog box:

"Don't worry we've got this. Why not do some tutorials while you wait?"

I hate it when programmers talk to the public in that "I'm friendly but I know better than you" tone. Or even like this. Or this

Despite my cynicism the download and install completed without error. So I could start the tutorial (again).

I followed the tutorial. There were a few mis-steps, but I noticed immediately that I felt at home, I knew my way around VS2015, while Android Studio was a new beast. As I saw the fragments of C# my annoyance at the huge Xamarin download began to float away.

I got these errors as I trundled along, for example: "This project contains resources that were not compiled":


Hmm. Ah. Does it? I'd followed the tutorial, so why the message? I closed the project and re-opened it, and all was well. Ah. Hmmm.

Then: "String types not allowed (at id with value..."


I was completely baffled by this one, and only a Google search for the exact phrase could resolve the question. I'd used " @+id/TranslateButton" instead of "@+id/TranslateButton". Spot the difference. There is a leading space in my erroneous version. My fault.

Once when I tried to open the layout of the screen I got a "Incorrect parameter" message box. Ok. Tried again and it worked. It feels like lots of complex, delicate and not bug free stuff is running around behind the scenes. Nervous making.

Then, after changing target Android versions (a slightly scary nightmare in itself) I got the "For some reason we could not reload the project." message:


"For some reason..."? "For some reason..."? What does that mean? It's a bit like the "Something went wrong" message I talked about in the previous post. The programmer who wrote that message...he's found out there's an error, but can't understand what it is. Hmmm.


Luckily since I'd already tested Android Studio the Android emulator was installed.  But it crashed or my program crashed or "something else went wrong" to use the technical gergo of Xamarin. Eventually, after fiddling around with SDK versions and emulated phones I got the Phone Word app to run. It crashed in the end, I think because I tried to phone from the emulator, and the emulator can't do that.

So...so I'm not used to getting errors like this in VS2015, C++ and C# for Windows. But I found myself anyway more comfortable in this more error prone environment than in Android Studio. 

So I'll probably stick to Xamarin in VS until I can see a compelling reason to change.
 

2016/12/13

How does Xamarin compare to Android Studio? (Something went wrong.)

Well, for a start, I found the Xamarin versions and options and downloads totally confusing. After a lot of work and a lot of hours uselessly downloading I've understood (maybe I'm wrong) that
  1. Xamarin Studio only really exists for the Mac (free).
  2. You can use Visual Studio (preferably 2015) with a Xamarin add on to create Xamarin programs.
  3. What is called Xamarin Studio for Windows is really "Mono", an open source program. It is hard to find out if it is still maintained and usable.

As I say I may be wrong and it took me a long time to garner even this little information.

I'm interested in Xamarin for two reasons
  1. I know C# so I don't have to learn Java, which I would have do with Android Studio.
  2. I know the VS2015 IDE, so I would not have to get used to the Android Studio way of doing things.
But what, I hear you say, about targetting Apple products, which is supposed to be the great advantage of using Xamarin? Here are the reasons I don't care about portability:

  1. Mr. Google tells me that in February 2016 Android devices had a 80.7 percent market share, while iOS recorded 17.7 percent market share (economic reason).
  2. I tried to write a program for the Apple Mac years ago, found the IDE a crashing disaster, help a crashing disaster, Objective C a bastard language (emotional reason).
As Android devices continue to fall in price I doubt that the iPhone market share will increase.

Anyway. After multiple attempts to get the Xamarin add-ins into VS2015 I work through an example project, and within 2 minutes I'm presented with this screen inside VS2015:






Hmmm. Android Studio is not looking so bad now. I have to go now, but I'll let you know if the update of the Android SDK improves anything...


13 hours later and the Android SDK manager is still downloading even though I unchecked all of the older versions...

 
Getting there...

2016/12/06

Running the Android Studio emulator

Ha! I'm beginning to grok this thing (a Robert Heinlein would have said).

When you click on the green run button in Android Studio...




...you need to have run the emulator at least once in that session to get it to appear in the list of available devices. Otherwise you just get a blank list. So if you intend to run your program in the emulator click on AVD manager:



On my machine the Tools menu is only built up over the first minute that Studio is run. So initially it only contains Tasks & Contexts and Save File as Template, which is disconcerting. You just have to be patient till al the menu items are loaded.


Then hopefully you'll see a list of virtual devices which you have previously set up. Once the emulator is running you can get your app running by pushing the main green button in Android Studio...



It did run but I got a scary message that I was trying to use 1500MB in a 512MB emulation.
Ah. What now? Mr google and stackoverflow came to the rescue by telling me to edit the virtual device, reducing the ram setting. 

If you are used to Windows changing the properties of something is often done with a right click and selection of properties. So I tried that. There was a menu, but no properties entry. Hmm. I put all three of my neurons to work and saw the pencil icon...





Clicking on the pencil gave me the dialog to change the ram size of the emulated device, once I'd click on "advanced". I found the edit box to change and clicked on Finish...







...But again Android Studio seemed to hang. It hadn't, but there was no indication (with a hourglass cursor or something) that it was working away properly. It was disconcerting.

In the end though changing the ram down to 512MB got rid of the warning.

I'm still not sure about Android Studio, it seems clunky and slow, but maybe Xamarin is worse! Which is the reason for these blog posts, I want to be able to compare the two...

Here's how I got on with Xamarin...

2016/12/05

Why I tried Android Studio first, and how I got on.

As I mentioned in my previous post, I have a 3 neuron brain, and I require clarity and simplicity to get anywhere in my thought processes.

Android and Android Studio seemed to me a good choice because everything was already set up. I just had to write the program, let Studio create the APK, and count the groats from the Android app store, or play shop or game supermarket or whatever it is called.





I was also attracted by the tutorials, there seemed to be a good place, developer.android.com, where I could follow step by step lessons in creating apps. It seemed to me that there was a one stop shop for writing, debugging, delivering and monetizing mobile apps. It was that in the end which decided me.

Xamarin lost because of the huge download, and JavaScript + HTML + Cordova lost because the tutorials I found seemed less appetising. Depending on how Android Studio goes I may come back to either or both of these.

So I downloaded and installed Android Studio, it took several hours, but seemed to go without problems, apart from a component download which failed, which it re-downloaded automatically without any prompting from me. I guess the whole download was about a fifth of the Xamarin one (which I never finished).

Once installed I noticed it seemed very very slow, especially compared to what I was used to with Visual Studio 2015.

Anyway I went here https://developer.android.com/training/basics/firstapp/index.html to learn how to write my first app with Android Studio.

You have to enable Developer Options in your device (smartphone or tablet)  if you want to be able to send APK files from Android Studio to it. If you can't see Developer Options under Settings go into the About Phone and tap the Build Number 7 times.  Developer Options is sometimes hidden by default, hence the 7 tap system to make sure it is only activated if you really really know what you are doing. Or at least think you know what you are doing.

All went well until I tried to load the program onto my Lenovo tablet. It is oldish, but I had selected the lowest Android OS (JellyBean I think it was) as the target of my simple app. Android Studio could not see the device:




"No USB devices or running emulations detected." Hmmm. I tried a phone, still same problem. I had to change USB socket. Then it worked. Compared with the first USB I used, the second working one was USB 2.0. Maybe that was the problem.

So. Voila.



You can just about see Hello World at top left.

The next lesson was about using an emulator to run your APK on a virtual Android device. I followed the steps and got to the final screen:



It was confusing because although Finish was not greyed out clicking on it did nothing. Casting my eyes around the dialog I see a "recommendation." A recommendation...what's that? A bit of advice?

"VT-x is disabled in BIOS" Hmmm. Is it? Do I care?

Will it run anyway? I mean. Maybe there is software emulation (which I thought this was) and fiddling with the BIOS will just make it run faster...? I mean, a recommendation is not an error is it? Yes it is.

I've never come across this ever before, but you need to enable hardware emulation in the BIOS before you can run the (software?) emulation of an Android device. Well if that it true the emulation must run really fast...!

I had to restart my computer three times before I found out which thing to click on the BIOS to enable virtualization, as it is called. On my machine it is this button:



I had to wait for a lot of things to get going inside Android Studio before the emulation would run. I mean, lots. In fact I thought the thing had crashed. So after a minute or so I pushed the RUN button again (it was alive and green, no indication that it should not / could not be pushed)... And I got this scary message:


I imagine that what had happened was that the emulator was still loading up its first instance, and there was no memory for two instances of the emulator. That is my guess. But it was unclear from the above message, so it is only a guess.

Finally I got to the stage of seeing my app in the emulator:



It takes time to gain confidence in a new development environment, but I am not impressed so far. It is very very slow, messages are ambiguous, greying out is not used (or is not used consistently) to indicate which buttons are validly actiove or not.

Still, I admit that a bit more experience may change my mind...

The next post is again about the emulator.

2016/12/04

Can I learn to program mobile devices?

Not sure how long this will last, but I'm doing these entries because
  1. I've heard that the best way to learn is to trying to teach what you are trying to learn. That seems to be have been true when I wrote my book "Candelas Lumens and Lux".
  2. I've learned so much from other blog posts maybe I should join the contributing community.
  3. Publicly committing to something makes it more likely that the thing will get done.
I was faffing around wondering which platform to use for a few ideas I have for mobile apps. I've already done one WEB app, which has had rather limited success (Ok, zero sales). It is a web site which allows you to create European Energy Labels. I did it because I know about the labels, and I wanted to learn C#/WEB apps and I hoped I'd be able to sell the service...


 
Despite the commercial failure of EuEnergyLabels.com I did learn about WEB apps and I did learn C# (which must rate as one of the very best computer languages ever invented). 

(I think I failed commercially because many of the labels had already been required by law for 4 years when I entered the market, so many large companies already had graphics studios or internal software for creating them.)

The energy label app works on all devices, Windows, Android, iPhone, Mac etc. So why not use the same technology (C# running on a web site) for my other ideas?

One thing I saw was that paid apps on Android devices often work by the user paying and downloading the APK (Android application package) of the full package, and that is that. With a web app how would I monetise the thing?

I found out that there are systems for turning a web page of javascript and HTML5 and graphic libraries into APKs, but I could not really find a clear simple explanation of it. And with a 3 neuron brain like mine clarity and simplicity are essential.

And anyway, was there a way of making a C# + site application into an APK? I did not want to learn a new language after discovering how great C# is.

So I came across Xamarin. Xamarin is a system which is supposed to port C# applications to all systems, including Windows, Android, Apple phones and Apple computers. I started to download it, but two things made me stop:

  1. It was HUGE. It looked to me as if it would take about 2 days to download everything.
  2. I saw that it looked (from the icons) like it installed Visual Studio. I don't know which version, but since I already have Visual Studo 2005 2010 2013 and 2015 on my PC I did not want some new installation to upset my money earning working compilations. Maybe a silly fear, I know.

Whether my reasons were good or not I interrupted the Xamarin download. I intend to look at Xamarin in another computer another day.

So I went back and looked again at HTML5 + JavaScript + ... + what? Cordova apparently,

Cordova seems to be a way of packaging your app so it will run on all mobile devices. But again the confusion in my mind put me off. Is it Apache? Why is there Cordova inside VS2015? Does Microsoft's Cordova compete with Microsoft's Xamarin? If so will one lose? Which one? How do I monetise? If it is Apache open source am I even legally allowed to monetise? What is Phone Gap? Who cares? Pass the whiskey. Can I have some ice in that?

My next post will be about my first Android app created with Android studio. And why I chose Android Studio.

If the self is an illusion...

If the self is an illusion (as some Buddhists and some pyschologists and some scientists say), then...er...who or what ...er... is "illuded"?
 
The definition of illusion is "a thing that is or is likely to be wrongly perceived or interpreted by the senses." So something/one percieves or interprets.

I've no doubt  "selves" change and die, but at the moment, now, who or what is having the illusion that the self exists?

(And for all those who say the self is an illusion I'd ask them to go and do some painful dental work without an anasthetic, and find out who or what feels the pain.)

But my main question remains who or what is illuded?