顯示具有 Android Development 標籤的文章。 顯示所有文章
顯示具有 Android Development 標籤的文章。 顯示所有文章

2012年11月25日 星期日

Andriod Permission: Connect to Internet



The following permission should be grant for the internet connection from Android Application.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... />
    ...
    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

[RESOLVED] E/ERR(1183): org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused

Today I am trying to write an android program to retrieve an XML data from localhost server. When running the program, the following error occurs:

E/ERR(1183): org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused




              String url = "http://localhost:100/test.xml";

              try {
                     DefaultHttpClient httpClient = new DefaultHttpClient();
                     HttpPost httpPost = new HttpPost(url);

                     HttpResponse httpResponse = httpClient.execute(httpPost);
              } catch (ClientProtocolException e1) {
                     // TODO Auto-generated catch block
                     e1.printStackTrace();
              } catch (IOException e1) {
                     // TODO Auto-generated catch block
                     e1.printStackTrace();
              }
             
 


Solution:
The Android emulator could not recognize the localhost and results in connection refused.
To resolve, we can change the localhost to the ip address 10.0.2.2 and try again, problem resolved.

e.g. String url = "http://10.0.2.2:100/test.xml";
 



2012年11月11日 星期日

[RESOLVED] INSTALL_FAILED_MISSING_SHARED_LIBRARY when using Google API

Today I'm trying to write Google Maps Application on Android. When running the application, the following errors occur:



[2012-11-11 20:20:45 - XXX] Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
[2012-11-11 20:20:45 - XXX] Please check logcat output for more details.
[2012-11-11 20:20:45 - XXX] Launch canceled!


Resolution:
It is because Google Maps is not installed on the device / emulator.

1. Choose the Android Version and install "Google APIs by Google Inc."

2. In project properties, choose Google APIs as the Project Build Target.

3. Build again and success!


2012年1月15日 星期日

Android Development for Beginner: Snake


This tutorial is for the beginner and demonstrate how to implement a tradition game "Snake" using Android 4.0.3.

The source code of this tutorial are extracted from the android developer official website and we will show you step by step on how to download and run the program. (http://yp-appdev.blogspot.com/)





2012年1月9日 星期一

[SOLVED]: Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder


System may returns error in creating an Android Virtual Device for the 4.0.x android ice cream sandwich and returns the error message in console
Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder.



Solution

Install ARM EABI v7a System Image and the problem is resolved! (http://yp-appdev.blogspot.com/)

After the installation, create the Android Virtual Device again and no errors found.


AVD Created


Success!




2012年1月2日 星期一

Using Eclipse to create an Android 4.0.x project

This tutorial shows how to create an Android 4.0.x project by using Eclipse, and create an Android

Before going thought this tutorial, you should install your eclipse as well as the android SDK in your machine, please take a look to my previous tutorial for the setup.
http://yp-appdev.blogspot.hk/2012/01/android-eclipse-development-platform.html
 
1. Create a new project by clicking File -> New -> Other


Android + Eclipse Development Platform Setup


The following tutorial shows how to setup the development environment for Android.

You have to install the following software in your machine.
- JAVA SDK
- Eclipse
- Android Development Kit

Steps by steps
1. Download and Install the latest version of the Java SDK.