Monday, June 6, 2016

Android studio upgrade to 2.1 broke my project

I decided to try out the new (and still in beta) Android studio 2.1 today. Easy peasy as usuall, just download and unzip and run studio.sh and everything starts up.

I suspected that it would not be as easy thou. I spend a lot of time (hobbytime) with bugs and issues in Android studio, the SDK management and the emulator. No changes in the dev environment comes without pain. And sure enough, I got a question about updating the gradle build files which probably broke the project.

I started getting some weird compilation errors regarding the appcompat style definitions.

Error retrieving parent for item: 
No resource found that matches the given name "Theme.AppCompat.Light.NoActionBar".

Google didn't help me much and I started trying to fix things. I spent maybe an hour trying to figure it out before I turned to source control. Which I should have done right away. Checking the git diff was all I needed. There, right before my eyes Android studio had simply washed away my project dependencies. This list was empty!

I took it all back. The only change I let Android studio have was the updated gradle version. That's it. And it was all that was needed. It works now, enough bleeding on the edge today.

Friday, April 22, 2016

Unity broke again, how to fix it.

Updated to Ubuntu 16.04 today. I always update as soon as I can. OS updates, as well as regular updates, does however have a tendency to break Unity. I bit too often I think. When it happens, there are millions of articles online on how to debug and try to fix it. I've come to a simple solution that always fixes this constantly regressing piece of software.

Step 1: Always accept the default settings. This makes step 2 easier.

Step 2: When it breaks:

sudo apt-get install unity-tweak-tool
unity-tweak-tool --reset-unity

Now you can keep using your Ubuntu like nothing happened. This method saves half a day of googling a few times a year.

Update 2016-04-30:

Seems that Xenial might not have been ready for release just yet. Further updates has broken unity once again. But, as previously stated, --reset-unity will fix it.

Thursday, April 21, 2016

Bleeding on the edge, Android development with DELETE_FAILED_INTERNAL_ERROR

I've been spending some time in Android Studio learning to develop android apps the last few weeks. And it is so extremely frustrating to consider how much time the development environment is stealing from me!

  • At home the emulator is really fast, but at work, with similar hardware and same OS it refuses to use acceleration.
  • The projects "break" every now and then. The "app" module is lost and nothing can be done but recreating the project again.
  • I forget to uncheck all those useless image updates when installing modules in the SDK. And have to wait for ever for them to download. Why are they checked by default every time?
And the last one. The one where the app refuses to install and you get the message
DEVICE SHELL COMMAND: pm uninstall your.package.name
DELETE_FAILED_INTERNAL_ERROR
Google has so many answers to this issue. Cleaning, restarting, reinstalling, deleting directories in Android and what not. Nobody seems to know why or what to do and yet it happens to me twice a week.

In the end there is only one solution that works, works fast and works every time. Go into the virtual device manager, click the drop down on your device and hit "Wipe Data"!


Stop spending time and try to fix this and just bite the bitter android until your lips start bleeding on the rough edges of the robot!

Monday, November 24, 2014

Broken VPN in Ubuntu 14.10 Utopic Unicorn

I spent a few hours today trying to figure out why my Open VPN connections refused to work. The only thing I got as a lead was a rather useless error message.

Failed to request VPN secrets #2: (6) No agents were available for this request.

Google only pointed by to obscure old bug reports or the Arch Linux fix. But the Arch fix was of no use in Ubuntu. Until finally I stumbled upon a solution (which I have now lost track of). It's rather simple, but be careful!

sudo apt-get remove --purge network-manager-gnome

Now reboot. Hopefully you'll come back online but without the widget when logging back in. Then, just reinstall the package.

sudo apt-get install network-manager-gnome

As a precaution, you can download the package, just in case your network doesn't work without the user widget.

Sunday, August 24, 2014

Tracking outbound links with google analytics, without annoying middle-clickers

As a quick and dirty solution I just added google analytics tracking of outbound links. It was really easy as I just borrowed a piece of code from this blog (kudos!). Everything went fine and the stats started coming in.

But when I later visited the site myself I realized something awful. Since I'm a obsessive middle-clicker opening all potentially interesting links in new tabs I ran into the issue immediately. It opens my middle-clicks in the same tab, transforming my middle-clicks to left-clicks.

Further googling explained everything. Many have written scripts like the one I picked and some have already considered this issue. So I read them all and improved the script I had stolen already. Here it is. Please comment if you think there's something wrong with it!


(function($) {
  "use strict";
  // current page host
  var baseURI = window.location.host;
  // click event on body
  $("body").on("click", function(e) {
    // abandon if link already aborted or analytics is not available
    if (e.isDefaultPrevented() || typeof ga !== "function") return;
    // abandon if no active link or link within domain
    var link = $(e.target).closest("a");
    if (link.length != 1 || baseURI == link[0].host) return;
    var normalClick = !e.metaKey && !e.crtlKey && e.which == 1;
    var href = link[0].href;
    var opts = {'hitType': 'event','eventCategory': 'outbound',
      'eventAction': 'link','eventLabel': href
    }
    if (normalClick) {
     // cancel event and record outbound link
     { opts.hitCallback = loadPage };
     e.preventDefault();
     ga('send', opts);
     // redirect after one second if recording takes too long
     setTimeout(loadPage, 1000);
    } else {
     // Just send the event
     ga('send', opts);
    }
    // redirect to outbound page
    function loadPage() {
      document.location = href;
    }
  });
})(jQuery);

Monday, August 11, 2014

Menu icons in eclipse linux

This very tiny issue in the linux version of Eclipse has bugged me for a couple of years. Despite the bug reports and suggested corrections I have not been able to get it to work. But today I somehow managed to figure it out. And the solution is very simple.

dconf write /org/gnome/desktop/interface/menus-have-icons true

Tuesday, May 14, 2013

Timezone fix for Liferay

Ever been annoyed that liferay logs in GMT/UTC even though you might be somewhere else in the world and you system is correctly setup in terms of time and zone? Judging from google results a lot of people seems to want to change this for some reason...

This is because someone at Liferay decided it would be best to override the system time zone in their bundled tomcat configuration. Great idea!

To fix this silliness just edit your setenv.sh and remove the chunk of characters that is saying: -Duser.timezone=GMT

There you go. One step closer to a sane Liferay environment.