Unknown Host Exception in Android
When you try to load something from web, and you have done almost everything right still you might get this exception.
1.) Change the host name ( here it is nopsa.hiit.fi) to the ip address of the host. It can work.
2.) Restart your emulator ( few times.. may be )
3.) add folowing code to AndroidManifest.xml
ActivityNotFoundException
When you try to load something from web, and you have done almost everything right still you might get this exception.
06-10 11:08:50.217: WARN/System.err(868): java.net.UnknownHostException: nopsa.hiit.fi 06-10 11:08:50.217: WARN/System.err(868): at java.net.InetAddress.lookupHostByName(InetAddress.java:497) 06-10 11:08:50.217: WARN/System.err(868): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:294) 06-10 11:08:50.217: WARN/System.err(868): at java.net.InetAddress.getAllByName(InetAddress.java:256) 06-10 11:08:50.237: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.Solutions:(HttpConnection.java:69) 06-10 11:08:50.237: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection. (HttpConnection.java:48) 06-10 11:08:50.272: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322) 06-10 11:08:50.272: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89) 06-10 11:08:50.272: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285) 06-10 11:08:50.277: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267) 06-10 11:08:50.277: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1018) 06-10 11:08:50.297: WARN/System.err(868): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:512)
1.) Change the host name ( here it is nopsa.hiit.fi) to the ip address of the host. It can work.
2.) Restart your emulator ( few times.. may be )
3.) add folowing code to AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />In some cases when you have'nt done the last change i suggested you might bet the following error as well.
06-10 22:47:29.866: WARN/System.err(380): java.net.SocketException: Permission denied 06-10 22:47:29.896: WARN/System.err(380): at org.apache.harmony.luni.platform.OSNetworkSystem.socket(Native Method) 06-10 22:47:29.946: WARN/System.err(380): at dalvik.system.BlockGuard$WrappedNetworkSystem.socket(BlockGuard.java:335) 06-10 22:47:29.946: WARN/System.err(380): at org.apache.harmony.luni.net.PlainSocketImpl.create(PlainSocketImpl.java:216) 06-10 22:47:29.997: WARN/System.err(380): at java.net.Socket.checkOpenAndCreate(Socket.java:802) 06-10 22:47:30.026: WARN/System.err(380): at java.net.Socket.connect(Socket.java:948) 06-10 22:47:30.026: WARN/System.err(380): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.(HttpConnection.java:75) 06-10 22:47:30.058: WARN/System.err(380): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection. (HttpConnection.java:48) 06-10 22:47:30.077: WARN/System.err(380): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322) 06-10 22:47:30.116: WARN/System.err(380): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89) 06-10 22:47:30.146: WARN/System.err(380): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285) 06-10 22:47:30.146: WARN/System.err(380): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267) 06-10 22:47:30.176: WARN/System.err(380): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.retrieveResponse(HttpURLConnectionImpl.java:1018) 06-10 22:47:30.186: WARN/System.err(380): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:512)
ActivityNotFoundException
06-10 22:50:18.256: ERROR/AndroidRuntime(572): FATAL EXCEPTION: main 06-10 22:50:18.256: ERROR/AndroidRuntime(572): android.content.ActivityNotFoundException: Unable to find explicit activity class {hiit.nopsa.pirate/hiit.nopsa.pirate.GameHome}; have you declared this activity in your AndroidManifest.xml? 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.app.Activity.startActivityForResult(Activity.java:2827) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.app.Activity.startActivity(Activity.java:2933) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.view.View.dispatchTouchEvent(View.java:3885) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.app.Activity.dispatchTouchEvent(Activity.java:2096) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.view.ViewRoot.handleMessage(ViewRoot.java:1878) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.os.Handler.dispatchMessage(Handler.java:99) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.os.Looper.loop(Looper.java:123) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at android.app.ActivityThread.main(ActivityThread.java:3683) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at java.lang.reflect.Method.invokeNative(Native Method) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at java.lang.reflect.Method.invoke(Method.java:507) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 06-10 22:50:18.256: ERROR/AndroidRuntime(572): at dalvik.system.NativeStart.main(Native Method)to fix this bug you should add the following code to the AndroidManifest.xml
<activity android:name=".ClassName"/>The ClassName should be replaced by your Class name which is a Activity.