Saturday, 01 June 2013

Using local .aar Android library packages in gradle builds

Since Gradle became the new build system for Android there were a lot of questions popping up all over the net about how to use it. The new build system comes with a number of great features like multi project builds, android archive packages (.aar) for android libraries and so on. Unfortunately, since the new build system is quite fresh (version 0.4.2 at the moment), the documentation is rather limited, so not everything is clear and simple.

For example, if you have a solution with an android library and an android app (that depends on the library), your build will work just fine. But what if you want to decouple the library, keep it separate so that you can use it in other projects or share it with the community? The Gradle build system will package it as an android archive package (.aar) and you can add that as a dependency to your projects. The only problem is that referencing .aar packages locally doesn't work very well, and it seems like that's by design. As explained by +Xavier Ducrichet in this comment:

"using aar files locally can be dangerous. I want to look at either detecting issues or putting huge warnings."

This means that to add a reference to an .aar package it it would have to ideally be stored in the central maven repository (now that maven central finally supports android archive packages!). But what if that's not an option, for example if the library you're referencing is in development?

(Read More)

Saturday, 25 May 2013

Referencing android library packages in Gradle

UPD: Seems like referencing local .aar packages is not recommended. But you can just as easily set them up in a local maven repo, which will work even better!

Using local .aar Android library packages in gradle builds


Playing with the new Gradle Android build system, I created some multi project setups, and it seems to work great! I had a project with a main android app, an android library and a java library all wired up and working well.

But once I tried to decouple the android library to a separate location, and just inject the .aar package in the project depencency list I ran into a problem. The project completely refused to build, stating:

:mainapp:packageDebug
Error: duplicate files during packaging of APK D:\Development\MyProject\mainapp\build\apk\mainapp-debug-unaligned.apk
        Path in archive: AndroidManifest.xml
        Origin 1: D:\Development\MyProject\mainapp\build\libs\mainapp-debug.ap_
        Origin 2: D:\Development\MyProject\mainapp\libs\AndroidExtensions.aar

Everything seemed to be configured correctly, the android library was producing a proper .aar library package file, and I was sure that it should work out of the box, but it was just refusing to work...

The solution was actually much simpler than I expected:

(Read More)

Adding support for AndroidAnnotations in Gradle projects

Recently I've started migrating my Android projects to the new Gradle build system, and I've been quite impressed. The new build system is quite powerful, but at the same time it is rather fresh, which means there are some things that aren't supported or documented yet.

One of the things that took me quite a bit of time to research and figure out was adding support for the AndroidAnnotations project. While it seems like the annotation building is enabled out of the box, this specific library has some characteristics that only make it work after some custom configuration. One of the main issues was the fact that the library is looking for the Android manifest file by going up from the generated files. And considering that the Gradle project structure is different compared to the old one, this causes issues.

(Read More)

Sunday, 26 June 2011

Dual Battery Widget for Android

This is one of my first projects for Android, and the first one that was released in the wild.

A Battery Widget that displays the status for the internal battery, and the secondary battery in your dock station. It is mostly intended for the Asus Eee Pad Transformer tablet (a device that actually has a second battery).

The widget is resizable, and can be as little as 1 cell on your screen, or fill your whole home screen! Advanced options allow you to change the size and the position of the status text, and hide the second battery gauge when it is disconnected. On devices without the dock the widget will only show the main battery icon.

(Read More)

Say Hello to Android

For the last month or so, I've been slowly entering a new territory for myself, a new development platform that I've hardly touched before. My new obsession is developing for Android!

Even though I've used smartphones for years and years, I never really got into mobile development. I've have been using Symbian and Windows Mobile based phones since 2005, I believe, and I only got a little past downloading the SDK. Once I got more serious about windows development (the C# era for me) I tried making some apps for Windows Mobile, but it never really stuck to me, never felt natural, or interesting.

Now, I've been using Android phones for almost a year now, and it proved to be really exciting. I love the platform, I love the community, I love the way it allows apps integrate with each other. It's something I haven't seen before, and more. So I decided to give it a try, and couldn't stop since!

At the moment, most of my free time I'm dedicating to the couple projects that I started. One of them it already out in the wild, and within a week it grew it's own fan base. The others are still in the incubation period, but I believe they're growing nicely. I should have some more updates soon about them, as well as my thoughts (and hopefully tips and tricks) about this big new world it opened for me.

Thursday, 24 February 2011

Server Manager 2008 failing to detect system status

While setting up a new server recently I ran into an unexpected problem. It was quite a straightforward setup, nothing unusual. A Server 2008 R2 os, with SQL, IIS, a couple basic services and the latest updates.

A couple restarts later, I open the server manager, and am greeted with a white page, and the request to check some error logs. Specifically the following branch: Event Viewer -> Applications and Services Logs -> Microsoft -> Windows -> ServerManager -> Operational. Inside, I've found a number of error logs, all of them complaining about the same thing:

Could not discover the state of the system. An unexpected exception was found:
System.Runtime.InteropServices.COMException (0x800F0818): Exception from HRESULT: 0x800F0818

With a system that was just installed the previous day, I could just drop it and start from scratch, but I didn't want to just give up. Plus, I was curious about what exactly was causing the problem. So I decided to dig deeper, and check online what exactly was the problem.

(Read More)

Returning at last

Seems like I've been missing from this blog for quite a while. And, honestly, it's not because I didn't have anything to write. In fact, I've had a whole number of interesting things that I could have written, but I've been busy at work, and I've never really managed to get some time to just stop and write a couple blog posts.

But I am coming back, and should have a number of posts ready within the coming weeks! So stay tuned, and enjoy :)

Tuesday, 18 May 2010

Object initialisers and Collections

Starting with .NET 3, we've received some pretty cool new syntax in C#, things that made coding a bit more pleasant, and the code look somewhat more tidy. One of these additions was the object initialiser syntax!

Basically, what it allows you to do is initialise an object, and assign a bunch of properties to this object in a single statement, instead of 1 statement per each assignment. Apart from reducing the number of statements, and grouping all these assignments (which improves readability as well), this was also used in initialising anonymous class variables, and using simple single-statement lambdas, but that's not the point of this page :)

While this works great in most cases, there's one situation where I thought I didn't have a choice than to assign some values outside the initialiser, and this was readonly collections! Because the object initialiser is used to assign values to properties, I couldn't use it to create a new object with some values in a readonly collection property, because every time I tried - I got a exception.

new DataTable
{
    Columns = new[] { new DataColumn("FirstCol") }
}

What I didn't know at the time was that this was easily fixed by using another well-known addition in .NET 3 - the array / collection initialiser!

(Read More)

Friday, 09 April 2010

Tag Cloud Sphere Leak

This is a VERY early version of the cloud sphere implementation in the HTML5 <canvas> element.

It's NOT optimised, NOT cleaned up.. and doesn't react to mouse clicks yet, but it should all come in soon. For now I'm just displaying that it's possible, and it works :)

Apart from the fact that it works only in the browsers that support HTML5 (duh!), it may have it's own quirks in some browsers. For example in Firefox the letters have a strange cyan-ish outline, and don't move very smooth. I've managed to fix it in Chrome though by rotating the canvas very slightly, but it was enough to force Chrome to render them differently.

Wasn't tested a lot (and I don't have a mac to test it there), so any feedback, advice and other comments will be greatly appreciated :)

P.S. Oh yeah, this is not a public release yet, so I'm not listing all the sources, but I've been taking ideas and some formulas from places.. All references will be accounted for when it's released.. I PROMISE :P

(Read More)

Monday, 05 April 2010

First release: IIS Log Inspector module

I've been wondering for a long time now - why does IIS manager not have some kind of log inspector.. ANY kind, even one that would simply open up the log file in a text editor! They simply force us to use third party apps, or open up the log files manually.

Lucky for us, IIS 7 was improved in many ways, and one of the new features is support for custom pluggable modules for the IIS manager! So I decided to write a basic module that will allow me to get a quick peek at what's been going on with the website. I don't want to replace big specialised tools that generate graphs, and give us all kinds of statistics - instead, I decided to get something simple that will let me get a quick look at the latest activity.

As the default format of the log files in IIS7 is W3C - I decided to support just that (at least for the moment). If I need something more at any other point in time - I'll be able to extend it, and so will anyone else if they need it!

The last reason for this post - I'm announcing (as if it were a big thing for anyone else :P ) that other than a blog - this website will host project pages. Each project page will give the readers a quick overview of the project, screen shots, installations instructions and download links!

More info, including download links are available at the project page: IIS 7 Log Inspector Module

Upd: The link ago has not been working in feed readers and on the home page for some time. Luckily - it's fixed now :)

Thursday, 01 April 2010

IIS 7 FTP Extensions - The Guide

For a couple of years now the FTP server we used at my full-time job was FileZilla. It's a good server, open source, easily configurable, stable. But one of the main features we needed was to be able to dynamically add and remove FTP users, each locked up in their own folder, all grouped in a couple of main Categories. The users were generated by the main ASP.NET powered web app, and had to be able to use their ftp accounts immediately.

FileZilla stores these accounts in an xml file, so to add new accounts we had to open up the xml, add the new user, save the configuration file, and poll the ftp server to reload it's config file. While this approach worked, it was far from perfect. And apart from the fact that we were storing the credentials in two places (they were stored in the main DB already) the main problem surfaced when 2 users tried to create accounts at the same time generating a file lock.

I wanted to move to a different server that would store all the credentials in a SQL database (ideally within our own structure), and I've finally found what I was looking for - Microsoft has released FTP7 - an ftp server that runs on IIS 7 (Windows Vista and higher only, sorry Win2003 :) )

The best thing about it is that you can write custom extensions for it that will control the authentication process, the user roles, the home folder, and logging. It sounds simple and straightforward at first, but it's not as perfect as we'd like at first. After working on it for the better part of a day (slowly becoming a long night) I decided to write this semi-definitive guide to setting up custom authentication in FTP 7!

(Read More)

Wednesday, 31 March 2010

Public announcement: The Big Bang

Update:

I'm updating the DNS entries, so if you see this update - you're looking at the brand new thing ;)
I've temporarily emulated the old blogger links for the feeds as well (the emulated links return the Atom feed) but I still recommend updating them to the new ones: Atom and Rss

No, the world isn't going to collapse on itself and explode (or implode? or both?). I'm just finally ready to leave Blogger, and host the blog by myself.

This will include having my own hosted website that will do all the cool bits behind the curtains. Of course it's not all going to be perfect, and the biggest hit will be a new link structure. The new engine will still have a redirect rule for the blogger's page url's, so that I won't lose the Google search ratings (as low as they are, they're still good, right? :) ), but the feed urls are going to change, so you'll have to update them soon!

I know this is long overdue, and I've been kind of ready for it for awhile now, but just didn't have the time and circumstances to do it. Also, pretty much none of the current hosters are ready to host .NET 4 code, so it has been holding me back as well.

(Read More)

Friday, 22 January 2010

Current progress: Open Id

I haven't been posting any updates on the blog system / cms that I'm writing lately, and it's mainly because there wasn't much to write about. With work and a bucket full of IRL issues, I didn't really have a lot of time to work on it, but I am not letting it drop away!

One of the things that I really wanted, while planning it was the ability to use my site as an OpenId provider. This way I could use it to log in into other systems, and have my profile link back to my site automatically. Yay to more visits!

Luckily for me, I didn't have to write the implementation from scratch, as there are ready-made libraries available out there, and the one that looked best for me was DotNetOpenAuth. It supports OpenId, OAuth, ICards, and is just simple and easy to use.

It didn't take me a lot of time, to set it up, and now I've got my own OpenId provider that can actually provide some info about me (using Simple Registration or Attribute Exchange), one feature that a lot of other providers I used completely ignored :S

Blog comments

I guess some of you have noticed the change the comments area on my blog. And to answer your question (if you did wonder in the first place) - yes, it's not a new style or skin. The comments aren't even hosted by Blogger / Google anymore!

I do kind of hate the comment system on blogger. I mean - yeah, it kind of works. But any kind of notifications are disabled by default, and you have to always "follow" posts to know if someone posted a reply to you, and if you forget - you might never know someone did at all!

Worst of all, the comments don't support threading. I mean, come on.. Thousands of websites online have at least some kind of "reply to comment" support. Whether it's just prefixing the comment with the parent comment number, or having full-featured threading with indentation =/

So anyway - I moved the comments to Disqus, but only temporarily. While I'm working on my blog engine (which will have it's own comment system, btw), I don't want to have a big mess in here. Furthermore - I'm getting instant notifications, threading and a moderation panel as well, not mentioning the ability to export all comments, so that I can import them in my system when I'm done :)

And to everyone using blogger, I still suggest: if you're not satisfied with what you have here - move to an external comments system. Whether it's Disqus, Intense Debate, or anything else.

Monday, 11 January 2010

rTorrent is OUT, Transmission is IN

Ok, I guess I started celebrating WAY too soon after my previous post. While the whole setup did look extremely satisfying it had a couple of drawbacks.

For example, I really got used to uTorrent's .!ut file extension. This way my media center didn't pick up files that weren't finished yet. Unfortunately I didn't find a nice way to do the same in rTorrent, but it wasn't crucial, so I let it go. Then the interface was sometimes failing to connect to rTorrent, and I was forced to refresh the page time after time until I got it up. The configuration file was rewritten as soon as you did an update of the application, so I was forced to keep local copies of my configured version, and so on.

But these were all small issues, and I could live with them, because I didn't know better. Until the app started hanging. Badly. As in it would just stop responding to anything. I could see it in screen, but couldn't do anything. The web interface just became useless at this point, with no chance of connecting to the RPC interface. And when the router started hanging because of it in the in the middle of my work day - I just killed the process (it didn't want to die either btw -.- ) and left it as it was.

Later, after a bit of searching, I saw that I wasn't the only one with these problems, and a number of people have moved on to Transmission. Not everyone, though, because for others it was just too complicated and advanced. Nonetheless it was praised as a powerful client, and at the same time very resource "safe". With a low memory imprint (rTorrent took hundreds of MB ram! Thank god for the swap drive :D ), and very few dependencies (rTorrent pulled up about 5 more packages, Transmission just required 2) it seemed like an awesome solution, so I decided to give it a try.

After installing it, and failing to understand what to do out of the box, I went to their website for some docs. With a nicely structured wiki, it took me only a couple of minutes to get a settings file (stored in the user's home dir btw, YAY!), start the service and connect to the in-build web interface! Furthermore, there's a .NET remote app that I could install locally, and control almost all functions from a nice and familiar interface.

Half an hour later, I have a new torrent app running, with everything I want. Unfinished file names, nice remote control options, authentication and IP bindings, and a warm fuzzy feeling of accomplishment inside :)

Pages: 12