Tuesday, July 31, 2012

"unable to resolve target" and "Unable to get system library for the project"

Have you even tried to import an Android Project into Eclipse, but get error like "unable to resolve target" and "Unable to get system library for the project" ? If so, this post may help.

 In sometimes, the error was caused by unavailable of certain Android SDK version. The project may be build based on a version of Android SDK, that your Eclipse had not installed.

To solve the issue, just following the steps below.

1. In Eclipse, right click your project > Properties.
2. Click Android, select a build target and "ok"
3, When you go back to Eclipse, clokc, Project > Clean > Clean all projects

Then back to your .java and all error should be removed.

p.s. The nice example was came from How to convert an Activity class to use with FragmentPagerAdapter

Report for Apple apps naming

Its always be a hard decision in naming my own apps. For me, I get to consider a few issues.

1. Descriptive - User get to know what you apps is through the name

2. Unique - Make your apps different from other

3. Simple - Easy to remember, so that it can be told to others!

For sure that I am not very well in apps naming.

How would you name your apps? See if you can be inspired by those Apple IOS developer.

Most commonly used wording in IOS apps name:
1. HD – 27777
2. Lite – 21690
3. Free – 18511
4. iPad – 11313
5. Pro – 9024
6. Guide – 8361
7. Mobile – 7695
8. App – 6142
9. iPhone – 5441
10. Game – 5377
11. Travel – 4851
12. Radio – 4633
13. World – 4504
14. Map – 4351
15. Dictionary – 4220
16. Edition – 4198
17. Calculator – 4164
18. Kids – 3852
19. English – 3680
20. News – 3611
21. Book – 3254
22. Magazine – 3009
23. Photo – 2957
24. Puzzle – 2835
25. Music – 2764

Which words do App developers most commonly use in their App titles?
Apps Score Report June 2012

Monday, July 30, 2012

"R cannot be resolved" error

For "R cannot be resolved" error, in most cases, the problem may relied on the Java itself, but /res/values/strings.xml. Make sure the syntax of XML is correct.

Sunday, July 29, 2012

Baby milkfeed counter

It help parent to record the volume of milk their baby taken. It also tell you your baby age and birthday! And the most amazing thing is ... its my first Android apps!

Localized  in English, Chinese, Simp. Chinese, Trad. Chinese

You may download the apps Baby milkfeed counter from Google Play .

Upgrade and Versioning of your apps

If you have developed feature or bug fix your Android apps, you have to change the version of your app, before you can upload it to Google Play.

versionCode - Integer only. That's the version of your application code. You must change (normally +1) its or Google Play will not allow you upload the APK.

versionName - String. Version name that all users can see. So that they can identify which version they are using. (normally in format like 1.0.2)

See more in Android Developer - Versioning Your Applications

Android 4.1 SDK (ADT 20.0.2) released

Google release its latest Android Development Tool 20 in July 2012. It includes tones of bug fix. What are you waiting for? Launch Eclipse and update your ADT ASAP?

Android Developer - ADT plug-in

Syntax Highlight for Blogger

Content of this blog contain source code of programming language, like XML & Java. For ease of reading, they are well formatted by SyntaxHighlighter .

The following described how to implement SyntaxHighlighter in Blogger.com

1. Login Blogger > Template > Edit HTML > Proceed

2. Copy & Paste the following code, just before </Head>. Then Save template. After that, Blogger template setup is completed

2. To add formatted code in to your Blogger, use wrap the content with the following tag.



You also get to edit the content by HTML as below.

The above example is for XML content. For other like Java, PHP, etc, see the table below

Here's a list of supported languages and their aliases:
Language Aliases
C++ cpp, c, c++
C# c#, c-sharp, csharp
CSS css
Delphi delphi, pascal
Java java
Java Script js, jscript, javascript
PHP php
Python py, python
Ruby rb, ruby, rails, ror
Sql sql
VB vb, vb.net
XML/HTML xml, html, xhtml, xslt

Please also check with SyntaxHighlighter website for other info.

SyntaxHighlighter in Google Code
SyntaxHighlighter web site

Saturday, July 28, 2012

Hiding Option Menu

In some situation, you developed an app with optional menu but wants temporary disable it for reason. You may use .setVisible(false).

Before move on to an example, I expect you are familiar with Android Option Menu, if not, please read this this first.

I have prepared an option menu defined below


          android:title="@string/importSD" />
            android:title="@string/exportSD" />
            android:title="@string/exportDropbox" />
            android:title="@string/unlinkDropbox" /> 
            android:title="@string/babyBirthday" /> 
            android:title="@string/info" />

Then, when the main java, add the following class and set your desired option menu to disable


	boolean isLiteVersion = true;
	public boolean onPrepareOptionsMenu (Menu menu) {
		if (isLiteVersion)	{
		return true;

Some of the option menu will then be be hidden.

Google Android Developer : Menu

Galaxy S3 LTE , an Android /w 2G RAM

The Samsung android smart phone Galaxy S3 was announced for sometimes. However, in some country, like Koren, the ram size is doubled and up to 2GB. The device was import to by a 3rd party phone store, and its maintenance was not covered by Samsung HK. It retail and price is nearly the same as its 1GB ram version in Hong Kong about HK$5,280.

During testing, the 2GB ram version S3 was found with 1.1GB free ram, interested?

You may read the review as below.

四核 2GB RAM:韓版 Galaxy S3 水貨實測

Developing multi-language Android app

Developing your apps with User Interface in Android is easy, but your get to follow the guidelines.
  • Don't hard code text. Use Resource (strings.xml).
  • Avoid integrate text into picture (icon, banner, etc)
  • Use short wording
Let see some an example.
The default language of the apps "Baby milkfeed counter" is English. That mean whatever you device language setting is, the apps will display UI in the English.

Let's focus on the field "Fed Today".


 The below is a extract of the /res/layout/main.xml. 

		        android:text="@string/fedToday" />

The above text "@string/fedToday" was a tag stored in /res/values/strings.xml. Text field stored in this file are default language in this app (i.e. English). Let see the extract content of this string.xml.


    Last feed time
    Last volume
    Since last feed
    Fed today
    Fed Yesterday

Rather than hard code the text "Fed Today" in /res/layout/main.xml , I store it as string in /res/values/strings.xml. In fact, you should store all the text that will display in UI in the strings.xml. To implement multilingual UI, I don't need to change other file, but just add another file, /res/value-<locale>/strings.xml.

For example, to implement the app's UI in Traditional Chinese, I just need to prepare another strings.xml, as in /res/values-zh-rTW/strings.xml.



The process is completed. As you can see, the UI development did not involved any Java code, or even any file, just string.xml. To switch between go to the Android setting change the Language. launcher icon and UI textwill changed based on the device setting.

For every setting language, you get to prepare a separate /res/value-<locale>/strings.xml. if the device can find the its own language's string.xml, it uses the default one. Language and the strings.xml path mapping is as below.

Default /res/value/strings.xml
CANADA  /res/value-en-rCA/strings.xml
CANADA-FRENCH  /res/value-fr-rCA/strings.xml
CHINA  /res/value-zh-rCN/strings.xml
CHINESE  /res/value-zh/strings.xml
ENGLISH  /res/value-en/strings.xml
FRANCE  /res/value-fr-rFR/strings.xml
FRENCH  /res/value-fr/strings.xml
GERMAN  /res/value-de/strings.xml
GERMANY  /res/value-de-rDE/strings.xml
ITALIAN  /res/value-it/strings.xml
ITALY  /res/value-it-rIT/strings.xml
JAPAN  /res/value-ja-rJP/strings.xml
JAPANESE  /res/value-ja/strings.xml
KOREA  /res/value-ko-rKR/strings.xml
KOREAN  /res/value-ko/strings.xml
PRC  /res/value-zh-rCN/strings.xml
SIMPLIFIED-CHINESE  /res/value-zh-rCN/strings.xml
TAIWAN  /res/value-zh-rTW/strings.xml
TRADITIONAL-CHINESE  /res/value-zh-rTW/strings.xml
UK  /res/value-en-rGB/strings.xml
US  /res/value-en-rUS/strings.xml

For more locale info  for Android Development  / SDK, check with the following

Supporting Different Languages



Stock Rom 4.1.1 for Nexus released

Google has just released it factory image for Nexus Device including Nexus S, Galaxy Nexus and Nexus 7. For those loving in flashing "Clean"  ROM, go ahead!

Please note flashing stock ROM will erase all existing data on your machine.

Factory Images for Nexus Devices

Android apps language translation

Google has provided an web-base translation tool which help developer to translate their apps content from one language to another. Google translate tool kit allow you to upload the strings.xml, and it will extract & translate only the tag content (but not full file). You can even review the translated tag one-by-one and make correction.

However, the result is not very fine for me. I guest Google get to work harder on its translation service.

Thursday, July 26, 2012

Smartone 4G launched in Hong Kong.

SmarTone will launch its 4G LTE network on 28 August 2012, with all current
SmarTone price plans applied. However, as a Android developer, I may not go for 4G now.

Lack of 4G developer machine
 Google recommended developer machines, Galaxy Nexus & Nexus S, do not have 4G support. I have no choice stay in 3G, in which what my Nexus can do

4G advantage 
4G takes the advantage of high speed transfer . However, my experience on 3G & Home broadband Wi-Fi makes no big different. Speed for 4G may not be a big deal for me, as 3G is god enough for me.

SmarTone Announces the Launch of its 4G Network

Netbean 7.2 released

Netbean 7.2 by Oracle was released and be available for download now.

However which Android will use NB in these day? Even Google tutorial are all in Eclipse, you do have to no choice but Eclipse.

NetBeans IDE 7.2 Release Information

Wednesday, July 25, 2012

Captuing Android emulator screen through Eclipse

After finished an Android apps, you may wish to a screen capture of your product.
There's various way to to cap those screen, but the easier way is to retrieve it from your Android Emulator. Lets see how to do these step-by-step.

1. In Eclipse, click Windows > Show View > Other

2. In show "Show View" window, select "Device" and click OK

3. You should then see a "Device" tag in lower right corner. Under "Name". Select your emulator and then click the Screen Capture button, as below.

4. The "Device Screen Capture" windows will prompt up then. Wait a few moment and you will see your apps screen. Click "Save" to store your screen, or copy, rotate, or what ever you want.


Monday, July 23, 2012

SDK for cloud storage

Dropbox vs Google Drive

There are 2 major cloud storage provider on Internet, Dropbox & Google Drive.

Both of them have free SDK for Android (IOS & more, too) for download. However, Dropbox has done a great job, much better Google. It takes the following advantages over Google.

Small - JAR is small in size , just ~50KB
Simple - With official 3 pages tutorial (Android), you will learn upload, download & search to/form Dropbox

For Google, I think what they have provided is a sophisticated framework for most language to get access to Google Drive. But the problem is, "it's not Android". I can't even find a "One Stop" official tutorial for Google Drive. So, let hope Google can release a full featured tutorial for Google Drive SDK 2.0, which announced on Google IO 2012.

For now, I choose Dropbox.

Dropbox SDK for Android
Google Drive SDK