Mono for Android Advantages and disadvantages

Source: Internet
Author: User

Recently interested in understanding Mono for andriod, which is used. NET platform to develop andriod programs. The Mono for Android API almost maps the standard Andriod API. For example, almost all of the same classes, methods, and fields are identical on both APIs. One of the main differences is that mono for Android uses attributes and delegates that do not exist in Java. I like the closely related two APIs because it makes it easy to switch back and forth between them and use the existing standard Android API documentation. I was able to successfully complete my project using Android, but there are still a few difficulties .... The pros and cons of Mono for Android are listed below:

Advantage:

1. Sharing code between platforms . If you work with the Mono Touch API with the Windows Phone API, you may reuse business logic code for the iphone and Windows Phone platforms. This is possible because everything can be done using a single encoding, a common programming language instead of 3 different programming languages. Note that although this applies only to business logic code, the rendering code for each platform will vary depending on the platform APIs. The ability to reuse code in my opinion is the best advantage of using mono fo Android.

2. use what you already have. NET skills. If you are more familiar with the. NET platform than the Java platform in your team, it is appropriate to use mono for Android. However, I think this advantage has been reduced by the fact that C # and Java are so similar. It is possible to use mono Touch, as this eliminates the need to learn the Objective-c form a learning curve, so there is a greater advantage than Java.

Disadvantage:

1. Performance issues. such as garbage collection, Mono for Android claims to support garbage collection, but there are some serious limitations that need to be noted. "GC does not complete the view of the process and may not run when it is insufficient, because the GC does not know that there is not enough memory. "Because this usually requires manual, whenever an activity is created to run garbage collection or destruction to free unused memory. Otherwise, an out-of-memory exception may be caused. I have encountered this problem more than once and have to use an alternative approach to solve the problem.

About Memory Management:
Many mono for Android are assigned objects for wrapping Java objects as their representatives. What happens: Every time you assign a wrapper type that corresponds to a Java type, you create two objects:
1). Java objects in the Java heap
2). Mono proxy object in mono heap
Mono for Android does not ensure that these two objects are referenced to each other for a long time to survive. That is, Mono's garbage collection refers to an object, and the Java-side object will remain alive and vice versa. The creation of this proxy object is mandroid.exe when the tool is compiled. However, the GC is lazy, run on demand collections, and not simply object out of scope. So this means that garbage across virtual machines is at least more than normal, which is unavoidable. Therefore, to allocate a large number object for temporary use, it is valuable to display the resources required to release those objects. The agreed method uses the Using keyword to new an object, and it is necessary to use the using clause to implicitly release the target's new object. Releases the JAVA-VM of the mono-side wrapper to collect objects, thereby preventing too many temporary objects from being associated together for a long time.

Go to the official website to learn more about Mono for Android garbage collection .

(This Xamarin team optimizes memory resource management: see:

http://developer.xamarin.com/guides/cross-platform/deployment,_testing,_and_metrics/memory_perf_best_practices/

)

2. third-party jar Libraries -Mono for Android is available for Android 4.2 release to bind any jar file support. The jar binding project is a good idea, but unfortunately this is unreliable. For simple jar files It is possible, but often not supported in a more complex Java library jar file. Xamarin provides some documentation on how to exclude the bind error jar, but it doesn't always help me. In future releases perhaps this feature will improve, but at present it is difficult to use, lack of documentation, and several well-known bugs.

3.bugs-- has a lot of bugs in mono for Android. Well, it may be important to be too strong a word, but certainly more stable to use Java versus mono for Android. The two most serious bugs I've ever met are: Date and time. The error is now returned in the UTC time zone, and an exception is caused when using SSL with WebClient.

A growing trend is to use standard Android and Java APIs to develop Android apps instead of using the C # and Mono Android APIs. That's because, first, Java has a good development community support, and second, using Java can cause fewer problems. However, the ability to share the same code in Android,iphone, and the Windows Phone and other platforms are appealing, so some cases need to be weighed.


Petter Liu
Source: http://www.cnblogs.com/wintersun/
This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.
The article was also published in my Independent blog-petter Liu blog.

(turn) Mono for Android advantages and disadvantages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.