Collection of Ionic / Android build errors and solutions

For me its always a struggle to get android sdk tools up and running on new systems. Especially if you use Ionic to build hybrid apps and Android Studio for building native android apps on the same system. In this blog I collect all the errors that I have encountered with solutions.

1. Compiling Ionic app

When I try to build my app and I run the command:
> Ionic run android
I get the following problem in windows.

Solution:

The solution to this problem is very simple when you know how to solve it 🙂
Go to Start → Control Panel → System → Advanced system settings → advanced(tab) → Environment Variables → System Variables → New:
Next add a new system variable:
Name: _JAVA_OPTIONS
Value: -Xmx512M

For me these solutions worked. If this didn’t work for you please add your solution to the comment with a reference to the problem number.
Please feel free to add your own errors and solutions to the comments below. Thanks 🙂

How to Configure a Self Referencing Entity in Code First

Recently I was working on a project that required a categorization option. I wanted the user to have the option to create categories and as many subcategories as they wanted. To realize this I created a category model that was self referencing:

It’s important that you don’t forget the Foreignkey data annotation because otherwise you will get an error like this:

Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements, or store-generated values.

Further make sure that ParentId is nullable because it makes no sense if every category has a parent if it was even possible.

Alternative

Instead of using data annotations you can also use Fluent API to create a self referencing model. When you choose for this approach add the following code to your DbContext:

More information

Some cool CSS stuff

css3-markupAfter my article about frontend development  where I particular focused on tools and javascript I will now focus more on CSS and styling. I can still remember the time when I started with web development and I used only inline styles. Now this is absolutely not done anymore. And that is very understandable considering that CSS has grown into a mature styling language nowadays and you don’t want to put all these logic in your html code.

Continue reading

Cross Domain Ajax with Cookies support using jQuery

Ajax requests are only possible when the protocol, domain and port number are the same. But sometimes you want to do Ajax calls to a different domain for example when you are creating a shared service that people should be able to call using Ajax or when you are developing locally and you are testing on a remote server. There are multiple ways to get around this restriction for example by using  CORS, an iFrame or JSONP. In my last project I got around the restriction using JSONP, so I will explain that here. See links for more information about solving it using CORS.

Continue reading

Floating point and Culture issues

Recently I was working on a ASP.NET MVC application where users could add budgets. The budgets were saved as floats. The problem was that some users used a (.) as decimal and others a (,). It depends on which culture setting your application is running if ModelState.isValid is true or false in such case. The culture setting in which your application runs depends on the system on which it is running. This is not a desired behaviour. Its better to specify the culture in the application itself and force users to use a (.) or (,). To run an ASP.NET MVC application in a specific culture setting you can add the following code to your Global.asax file:

More information:
http://stackoverflow.com/questions/19905694/c-sharp-mvc-4-model-changing-floating-point