Archive for the 'Unity Android' Category



APK Could not be installed

I was inspired this past weekend and went through a personal coding marathon. While doing some experiments and making observations I accidentally stumbled on an idea for a new game. This game would be so inspiring that I had it 90% complete after 30 hours of coding (or roughly 2.5 days).

I spent the next two days tweaking it and showing it to people who’s opinions I respect and am getting ready to release it into the Google Marketplace tonight.  In Unity (as with all apps) you need to set up a Keystore and sign your application. This is standard practice and the only speedbump I ran into was needing to put the path to the jdk\bin directory in my system path…

I finally have Unity export my finished APK and attempt to install it on my phone. Everything appears to be going great. The installation bar is chugging away and then all of a sudden I am hit with an incredibly ambiguous error:

APK Could not be installed.

The only option was to hit “OK”…. really? No further explanation? I’ve installed this APK dozens of times and have never had a problem… what changed? I deleted the .apk and re-transferred it over. I rebuilt it several times in Unity but I kept getting hit with the same error: “APK Could not be installed.”

The answer turned out to be fairly simple. I changed the certificate when I signed the game, and Android prevents this as a security measure. All I had to do was uninstall my game from my phone and then install the new APK. Trying to “overwrite” the APK with a different certificate is what causes this error.

Should have been obvious, but for me it just wasn’t…

Advertisements

Things not to do in Unity Android

Today marks my 6th day deving with Unity Android Pro, and I’m not going to lie… it’s been a very frustrating week.  I’ve got enough material to fuel four or five posts, but I’ll try to keep this one brief and hopefully help some people out.

Firstly, let me remind everyone that I was a Flash dev for the better part of a decade, and unfortunately this has permanently damaged my programming mindset. In Flash you find yourself moving objects around the stage in incremental steps… something along the lines of:

player.x += 1;

In flash this is fine.. and if you’re going to move things in Unity this kind of method works too… But that’s Unity for PC or Web… Now we’re working with Unity Android…

If you take anything away from this post, please take this. Android only cares about one thing. CPU Cycles. If you have an update loop and you’re moving something with += 1, you’re going to hate yourself.  Things will run very choppy, laggy, and freezy (depending on your phone). The most frustrating thing is when you’re testing this on your PC or Mac, it’ll work just fine! That’s because your PC and Mac process things completely differently than Android.

The tools you’ll use in Unity to save you from all this is Lerp, Slerp, and Translate. Also Mathf.Clamp, Floor, and Ceil are super important because Android will not calculate math quickly enough to keep up with your loop.  For example, say you want to rotate an object 90 degrees… well you better write that 90 degrees like Mathf.Ceil(90) otherwise your object will miss the 90 mark completely and keep spinning.

So remember kids, Lerp, Slerp, Translate and use your Mathf or you’ll be sorry…