I have UnknownHostExeption, when i am using proxy. My App works finy in networks without proxy or with some proxies( not everyone).
I am aware that I need to setup proxy setings for networks with them
for device: wify settings - advance - wifi proxy
emulator: wireless networks - mobile networks - access points - telkia - proxy|port.
I wish to know which essential options I have to ask admins to unlock for stable network comunications.
07-18 08:51:26.780: W/System.err(302): java.net.UnknownHostException: mirkvartir.ua
07-18 08:51:26.780: W/System.err(302): at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
07-18 08:51:26.780: W/System.err(302): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
07-18 08:51:26.780: W/System.err(302): at java.net.InetAddress.getAllByName(InetAddress.java:242)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
07-18 08:51:26.780: W/System.err(302): at ua.mirkvartir.android.frontend.adapter.JSONParser.getJSONFromUrl(JSONParser.java:98)
07-18 08:51:26.780: W/System.err(302): at ua.mirkvartir.android.frontend.adapter.UserFunctions.loginUser(UserFunctions.java:76)
07-18 08:51:26.787: W/System.err(302): at ua.mirkvartir.android.frontend.LoginActivity$Login.doInBackground(LoginActivity.java:185)
07-18 08:51:26.787: W/System.err(302): at ua.mirkvartir.android.frontend.LoginActivity$Login.doInBackground(LoginActivity.java:1)
07-18 08:51:26.787: W/System.err(302): at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-18 08:51:26.787: W/System.err(302): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-18 08:51:26.787: W/System.err(302): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-18 08:51:26.787: W/System.err(302): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
07-18 08:51:26.787: W/System.err(302): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
07-18 08:51:26.787: W/System.err(302): at java.lang.Thread.run(Thread.java:1096)
Answer is, you cannot tell in general. This is not Android-specific, but depends on your App. You're free to choose the ports it communicates over. Usually, 80 and 443 shouldn't be blocked (http / https) - everything else depends on your App.
What services do you use? If you never specified a port explicitly, they might imply one.
Related
installed XAMPP server, created database and successfully accessed it from chrome browser as well as from android emulator. However whenever i try to run application from my Samsung device, its refusing to connect my IP address.
My IP address is not registered in DNS.
I tried:
1) accessing from url- 127.0.0.1 and localhost
2) modified httpd.conf and httpd-xampp.conf file- changed to Require all granted permission
3) uninstalled my Antivirus
4) changed firewall and proxy setting
5) Created new Inbound Rule in firewall advance security
6) re typed INTERNET permission
7) wrote httpPost.setHeader("Accept", "application/json"); in code
Still Im getting following error:
W/IInputConnectionWrapper(22232): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(22232): setComposingText on inactive InputConnection
W/IInputConnectionWrapper(22232): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(22232): setComposingText on inactive InputConnection
D/request!(22232): starting
W/System.err(22232): org.apache.http.conn.HttpHostConnectException: Connection to
http://192.XXX.X.XXX refused
W/System.err(22232): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
W/System.err(22232): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
W/System.err(22232): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
W/System.err(22232): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
W/System.err(22232): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
W/System.err(22232): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
W/System.err(22232): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
W/System.err(22232): at com.example.mysqltest.JSONParser.makeHttpRequest(JSONParser.java:111)
W/System.err(22232): at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:121)
W/System.err(22232): at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:1)
W/System.err(22232): at android.os.AsyncTask$2.call(AsyncTask.java:287)
W/System.err(22232): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
W/System.err(22232): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
W/System.err(22232): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
W/System.err(22232): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
W/System.err(22232): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
W/System.err(22232): at java.lang.Thread.run(Thread.java:856)
W/System.err(22232): Caused by: java.net.ConnectException: failed to connect to /192.168.0.114 (port 80): connect failed: ETIMEDOUT (Connection timed out)
W/System.err(22232): at libcore.io.IoBridge.connect(IoBridge.java:114)
W/System.err(22232): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
W/System.err(22232): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:460)
W/System.err(22232): at java.net.Socket.connect(Socket.java:832)
W/System.err(22232): at `enter code here`org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
W/System.err(22232): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
W/System.err(22232): ... 16 more
W/System.err(22232): Caused by: libcore.io.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
W/System.err(22232): at libcore.io.Posix.connect(Native Method)
W/System.err(22232): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
W/System.err(22232): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
W/System.err(22232): at libcore.io.IoBridge.connect(IoBridge.java:112)
W/System.err(22232): ... 21 more
E/Buffer Error(22232): Error converting result java.lang.NullPointerException
E/JSON Parser(22232): Error parsing data org.json.JSONException: End of input at character 0 of
W/dalvikvm(22232): threadid=12: thread exiting with uncaught exception (group=0x41180438)
E/AndroidRuntime(22232): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime(22232): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(22232): at android.os.AsyncTask$3.done(AsyncTask.java:299)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime(22232): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
E/AndroidRuntime(22232): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
E/AndroidRuntime(22232): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
E/AndroidRuntime(22232): at java.lang.Thread.run(Thread.java:856)
E/AndroidRuntime(22232): Caused by: java.lang.NullPointerException
E/AndroidRuntime(22232): at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:125)
E/AndroidRuntime(22232): at com.example.mysqltest.Login$AttemptLogin.doInBackground(Login.java:1)
E/AndroidRuntime(22232): at android.os.AsyncTask$2.call(AsyncTask.java:287)
E/AndroidRuntime(22232): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime(22232): ... 5 more
I/Choreographer(22232): Skipped 1143 frames! The application may be doing too much work on its main thread.
E/WindowManager(22232): Activity com.example.mysqltest.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#41bea8a8 that was originally added here
E/WindowManager(22232): android.view.WindowLeaked: Activity com.example.mysqltest.Login has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#41bea8a8 that was originally added here
E/WindowManager(22232): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:419)
E/WindowManager(22232): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:322)
E/WindowManager(22232): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:234)
E/WindowManager(22232): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:153)
E/WindowManager(22232): at android.view.Window$LocalWindowManager.addView(Window.java:557)
E/WindowManager(22232): at android.app.Dialog.show(Dialog.java:277)
E/WindowManager(22232): at com.example.mysqltest.Login$AttemptLogin.onPreExecute(Login.java:103)
E/WindowManager(22232): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:586)
E/WindowManager(22232): at android.os.AsyncTask.execute(AsyncTask.java:534)
E/WindowManager(22232): at com.example.mysqltest.Login.onClick(Login.java:77)
E/WindowManager(22232): at android.view.View.performClick(View.java:4191)
E/WindowManager(22232): at android.view.View$PerformClick.run(View.java:17229)
E/WindowManager(22232): at android.os.Handler.handleCallback(Handler.java:615)
E/WindowManager(22232): at android.os.Handler.dispatchMessage(Handler.java:92)
E/WindowManager(22232): at android.os.Looper.loop(Looper.java:137)
E/WindowManager(22232): at android.app.ActivityThread.main(ActivityThread.java:4960)
E/WindowManager(22232): at java.lang.reflect.Method.invokeNative(Native Method)
E/WindowManager(22232): at java.lang.reflect.Method.invoke(Method.java:511)
E/WindowManager(22232): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
E/WindowManager(22232): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
E/WindowManager(22232): at dalvik.system.NativeStart.main(Native Method)"
Please try to check your local IP address of your PC. Connect the phone to the same network (WIFI). Then use the following address/port to connect to your PC.
In Android:
URL: your_pc_local_ip
PORT: 80 (but I think it is not mandatory)
I use in this way and it is working properly for me.
I'm doing an app in which a Service initiates a GPSListener which gets location updates in a regular interval of time.Upto this part its woking fine,and Im getting updates correctly.
I need to update this lat,long values to a server database,for which I use a http post request to a php script;which individually works fien.But when its called inside the LocationListener,Im getting the following error stacktrace.
How can I overcome this situation and make the post request?
> android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at com.childtrack.service.SimpleService$mylocationlistener.postData(SimpleService.java:165)
at com.childtrack.service.SimpleService$mylocationlistener.onLocationChanged(SimpleService.java:101)
at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:237)
at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:170)
at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:186)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4899)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
W/System.err(5560): android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
at com.childtrack.service.SimpleService$mylocationlistener.postData(SimpleService.java:165)
at com.childtrack.service.SimpleService$mylocationlistener.onLocationChanged(SimpleService.java:101)
at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:237)
at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:170)
at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:186)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4899)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
at dalvik.system.NativeStart.main(Native Method)
you are doing network operation on main(UI) thread. do use asyntask for network operation.
android does not allow to perform network operation on main thread. because it may freezes the UI.
whenever this exception occur android.os.NetworkOnMainThreadException its mean you have done something network operation on UI.
Even though Service is intended for background processing they run in the main thread .
A short quote from the documentation:
Caution: A services runs in the same process as the application in which
it is declared and in the main thread of that application, by default. So,
if your service performs intensive or blocking operations while the user
interacts with an activity from the same application, the service will
slow down activity performance. To avoid impacting application performance,
you should start a new thread inside the service.
I'm new to developing for Android and I'm having trouble launching my project. Whenever I launch it, it crashes and I get an error. I've put breakpoints throughout my code but it crashes before it reaches them. Here is the output from LogCat:
07-18 18:22:17.695: I/System.out(32229): Sending WAIT chunk
07-18 18:22:17.695: W/ActivityThread(32229): Application com.amvara.skatometer is waiting for the debugger on port 8100...
07-18 18:22:17.945: I/dalvikvm(32229): Debugger is active
07-18 18:22:18.095: I/System.out(32229): Debugger has connected
07-18 18:22:18.095: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.295: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.500: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.700: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.900: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.100: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.300: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.500: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.705: I/System.out(32229): debugger has settled (1434)
07-18 18:22:19.735: W/dalvikvm(32229): Unable to resolve superclass of Lcom/amvara/skatometer/ItemListActivity; (29)
07-18 18:22:19.735: W/dalvikvm(32229): Link of class 'Lcom/amvara/skatometer/ItemListActivity;' failed
07-18 18:22:19.745: D/AndroidRuntime(32229): Shutting down VM
07-18 18:22:19.745: W/dalvikvm(32229): threadid=1: thread exiting with uncaught exception (group=0x410d62a0)
07-18 18:22:19.780: E/AndroidRuntime(32229): FATAL EXCEPTION: main
07-18 18:22:19.780: E/AndroidRuntime(32229): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.amvara.skatometer/com.amvara.skatometer.ItemListActivity}: java.lang.ClassNotFoundException: com.amvara.skatometer.ItemListActivity
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2024)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.access$600(ActivityThread.java:140)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.os.Looper.loop(Looper.java:137)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.main(ActivityThread.java:4898)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.reflect.Method.invoke(Method.java:511)
07-18 18:22:19.780: E/AndroidRuntime(32229): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
07-18 18:22:19.780: E/AndroidRuntime(32229): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
07-18 18:22:19.780: E/AndroidRuntime(32229): at dalvik.system.NativeStart.main(Native Method)
07-18 18:22:19.780: E/AndroidRuntime(32229): Caused by: java.lang.ClassNotFoundException: com.amvara.skatometer.ItemListActivity
07-18 18:22:19.780: E/AndroidRuntime(32229): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.Instrumentation.newActivity(Instrumentation.java:1057)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2015)
07-18 18:22:19.780: E/AndroidRuntime(32229): ... 11 more
I can't figure out why this would happen because it isn't even hitting a breakpoint in my code. It must be a problem in the auto-generated Android code. Here's my AndroidManifest.xml, if you need it:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amvara.skatometer"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.amvara.skatometer.ItemListActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.amvara.skatometer.ItemDetailActivity"
android:label="#string/title_item_detail"
android:parentActivityName=".ItemListActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ItemListActivity" />
</activity>
<activity
android:name="com.amvara.skatometer.Bottom_panel"
android:label="#string/title_activity_bottom_panel" >
</activity>
<activity
android:name="com.amvara.skatometer.General"
android:label="#string/title_activity_general" >
</activity>
<activity
android:name="com.amvara.skatometer.SettingsActivity"
android:label="#string/title_activity_settings" >
</activity>
</application>
</manifest>
Thanks.
Try to clean your project, then you can also change :
<activity
android:name="com.amvara.skatometer.ItemListActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
[...]
</activity>
By
<activity
android:name=".ItemListActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
[...]
</activity>
It append to me one time but after all modification, doesn't work so I recreate the project from scratch and imported all my class, layout, etc. At the end, works as well.
i have an android app that need to show ads by AdMob.
here's my Log:
07-18 01:55:53.116: INFO/Ads(8682): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":0,"u_sd":1.5,"slotname":"**************","u_w":320,"msid":"com.paladin.hilula","cap":"m","adtest":"on","js":"afma-sdk-a-v4.1.0","isu":"*********************************","format":"320x50_mb","net":"ed","app_name":"1.android.com.paladin.hilula","hl":"hd","u_h":569,"testing":1,"u_audio":1,"u_so":"p"});</script></head><body></body></html>
07-18 01:55:54.187: INFO/Ads(8682): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?preqs=0&u_sd=1.5&slotname=**************&u_w=320&msid=com.paladin.hilula&cap=m&adtest=on&js=afma-sdk-a-v4.1.0&isu=*************************&format=320x50_mb&net=ed&app_name=1.android.com.paladin.hilula&hl=hd&u_h=569&testing=1&u_audio=1&u_so=p&output=html®ion=mobile_app&u_tz=-180&ex=1&client_sdk=1", "afmaNotifyDt": "null">
07-18 01:56:15.288: WARN/Ads(8682): IOException connecting to ad url.
07-18 01:56:15.288: WARN/Ads(8682): java.net.SocketTimeoutException: Connection timed out
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.platform.OSNetworkSystem.connect(Native Method)
07-18 01:56:15.288: WARN/Ads(8682): at dalvik.system.BlockGuard$WrappedNetworkSystem.connect(BlockGuard.java:357)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:204)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:437)
07-18 01:56:15.288: WARN/Ads(8682): at java.net.Socket.connect(Socket.java:983)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:75)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205)
07-18 01:56:15.288: WARN/Ads(8682): at b.a(Unknown Source)
07-18 01:56:15.288: WARN/Ads(8682): at b.doInBackground(Unknown Source)
07-18 01:56:15.288: WARN/Ads(8682): at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
07-18 01:56:15.288: WARN/Ads(8682): at java.lang.Thread.run(Thread.java:1019)
07-18 01:56:15.296: INFO/Ads(8682): onFailedToReceiveAd(A network error occurred.)
i get the URL but cant show it.
in manifest:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
in .java:
// Create the adView
AdView adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="#+id/mainLayout"
RelativeLayout layout = (RelativeLayout)findViewById(R.id.rlayout);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
AdRequest r = new AdRequest();
r.setTesting(true);
r.addTestDevice("*****************************");
adView.loadAd(r);
The /etc/hosts file on your phone has aliased r.admob.com to 127.0.0.1. I had this occur when I used a flashed ROM on my phone -- the ROM defined a whole bunch of entries like that so I'd never get ads. Which was great until I was testing my own ad-enabled app :-)
Edit your /etc/hosts and take out that entry.
AdMob's server (like any high volume server) can take too long to respond sometimes. It is better that you design with failure like this as expected behavior.
If you think there is more to it than that. Post what you are seeing that makes you think something else may be going on.
I am facing an issue with AsynsTask in my Application. I really do not understand the reason of it happening.
The issue is "The application works perfectly usually, now when any of the activity is displayed on the screen and I keep my device idle for a longer period of time. Then when I make the keyguard on the view of the last active activity is displayed to me. But as soon as I click on any component below mentioned exception is thrown. If the device is not kept for a longer period of time then there is no problem as such. The application makes http connection in onResume of most of the activities. I did this since every time the user comes to particular view then he should get the updates lists of posts from the webservice"
W/AsyncTask(18829): java.lang.InterruptedException
W/AsyncTask(18829): at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1254)
W/AsyncTask(18829): at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:219)
W/AsyncTask(18829): at java.util.concurrent.FutureTask.get(FutureTask.java:82)
W/AsyncTask(18829): at android.os.AsyncTask$3.done(AsyncTask.java:196)
W/AsyncTask(18829): at java.util.concurrent.FutureTask$Sync.innerCancel(FutureTask.java:293)
W/AsyncTask(18829): at java.util.concurrent.FutureTask.cancel(FutureTask.java:75)
W/AsyncTask(18829): at android.os.AsyncTask.cancel(AsyncTask.java:325)
W/AsyncTask(18829): at com.babbleville.utils.BabbleVilleSyncTask.doInBackground(BabbleVilleSyncTask.java:73)
W/AsyncTask(18829): at com.babbleville.utils.BabbleVilleSyncTask.doInBackground(BabbleVilleSyncTask.java:1)
W/AsyncTask(18829): at android.os.AsyncTask$2.call(AsyncTask.java:185)
W/AsyncTask(18829): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
W/AsyncTask(18829): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
W/AsyncTask(18829): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
W/AsyncTask(18829): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
W/AsyncTask(18829): at java.lang.Thread.run(Thread.java:1096)
W/InputManagerService( 85): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#44daac80
D/NetworkStateTracker( 85): setDetailed state, old =CONNECTED and new state=DISCONNECTED
D/NetworkStateTracker( 85): setDetailed state, old =CONNECTED and new state=OBTAINING_IPADDR
D/WifiStateTracker( 85): DhcpHandler: DHCP request started
D/ConnectivityService( 85): ConnectivityChange for WIFI: CONNECTING/OBTAINING_IPADDR
D/ConnectivityService( 85): Dropping ConnectivityChange for WIFI: CONNECTING/OBTAINING_IPADDR
I/AudioHardwareQSD( 59): AudioHardware pcm playback is going to standby.
I/System.out(18829): URL for Subsection Bookmark reply ==> http://www.softwebdemo.com/viral/babbleville/services/getvilledetails.php?action=getbookmarksubsection&Userid=51&start=0&end=30
W/dalvikvm(18829): threadid=10: thread exiting with uncaught exception (group=0x4001d7f0)
E/AndroidRuntime(18829): FATAL EXCEPTION: AsyncTask #3
E/AndroidRuntime(18829): java.lang.RuntimeException: An error occured while executing doInBackground()
E/AndroidRuntime(18829): at android.os.AsyncTask$3.done(AsyncTask.java:200)
E/AndroidRuntime(18829): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
E/AndroidRuntime(18829): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
E/AndroidRuntime(18829): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
E/AndroidRuntime(18829): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
E/AndroidRuntime(18829): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
E/AndroidRuntime(18829): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
E/AndroidRuntime(18829): at java.lang.Thread.run(Thread.java:1096)
E/AndroidRuntime(18829): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
E/AndroidRuntime(18829): at android.os.Handler.<init>(Handler.java:121)
E/AndroidRuntime(18829): at android.app.Dialog.<init>(Dialog.java:101)
E/AndroidRuntime(18829): at android.app.AlertDialog.<init>(AlertDialog.java:63)
E/AndroidRuntime(18829): at android.app.AlertDialog.<init>(AlertDialog.java:59)
E/AndroidRuntime(18829): at android.app.AlertDialog$Builder.create(AlertDialog.java:786)
E/AndroidRuntime(18829): at com.babbleville.utils.BabbleVilleSyncTask.AlertOnInternetConnetion(BabbleVilleSyncTask.java:188)
E/AndroidRuntime(18829): at com.babbleville.utils.BabbleVilleSyncTask.checkInternetConnetion(BabbleVilleSyncTask.java:169)
E/AndroidRuntime(18829): at com.babbleville.utils.BabbleVilleSyncTask.doInBackground(BabbleVilleSyncTask.java:57)
E/AndroidRuntime(18829): at com.babbleville.utils.BabbleVilleSyncTask.doInBackground(BabbleVilleSyncTask.java:1)
E/AndroidRuntime(18829): at android.os.AsyncTask$2.call(AsyncTask.java:185)
E/AndroidRuntime(18829): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
E/AndroidRuntime(18829): ... 4 more
W/ActivityManager( 85): Force finishing activity com.babbleville/.VilleBookmarkReply
E/WindowManager(18829): Activity com.babbleville.VilleBookmarkReply has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#44a25940 that was originally added here
E/WindowManager(18829): android.view.WindowLeaked: Activity com.babbleville.VilleBookmarkReply has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView#44a25940 that was originally added here
E/WindowManager(18829): at android.view.ViewRoot.<init>(ViewRoot.java:247)
E/WindowManager(18829): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
E/WindowManager(18829): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
E/WindowManager(18829): at android.view.Window$LocalWindowManager.addView(Window.java:424)
E/WindowManager(18829): at android.app.Dialog.show(Dialog.java:241)
E/WindowManager(18829): at com.babbleville.utils.BabbleVilleSyncTask.onPreExecute(BabbleVilleSyncTask.java:48)
E/WindowManager(18829): at android.os.AsyncTask.execute(AsyncTask.java:391)
E/WindowManager(18829): at com.babbleville.VilleBookmarkReply.loadSubsectionBookmark(VilleBookmarkReply.java:1186)
E/WindowManager(18829): at com.babbleville.VilleBookmarkReply.loadBookmarkSubsection(VilleBookmarkReply.java:1171)
E/WindowManager(18829): at com.babbleville.VilleBookmarkReply.onClick(VilleBookmarkReply.java:277)
E/WindowManager(18829): at android.view.View.performClick(View.java:2408)
E/WindowManager(18829): at android.view.View$PerformClick.run(View.java:8816)
E/WindowManager(18829): at android.os.Handler.handleCallback(Handler.java:587)
E/WindowManager(18829): at android.os.Handler.dispatchMessage(Handler.java:92)
E/WindowManager(18829): at android.os.Looper.loop(Looper.java:123)
E/WindowManager(18829): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/WindowManager(18829): at java.lang.reflect.Method.invokeNative(Native Method)
E/WindowManager(18829): at java.lang.reflect.Method.invoke(Method.java:521)
E/WindowManager(18829): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/WindowManager(18829): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/WindowManager(18829): at dalvik.system.NativeStart.main(Native Method)
D/NetworkStateTracker( 85): setDetailed state, old =OBTAINING_IPADDR and new state=CONNECTED
D/ConnectivityService( 85): ConnectivityChange for WIFI: CONNECTED/CONNECTED
D/WifiWatchdogService( 85): (android.server.ServerThread) Softwebsolutions (00:25:9c:0c:2d:c0) does not require the watchdog
D/ConnectivityService( 85): adding dns 192.168.3.105 for WIFI
D/Tethering( 85): Tethering got CONNECTIVITY_ACTION
D/Tethering( 85): MasterInitialState.processMessage what=3
E/HierarchicalStateMachine( 85): TetherMaster - unhandledMessage: msg.what=3
I/GTalkService( 214): [ServiceAutoStarter] --- connectivity changed
Can someone let me know the reason behind this error and any solution to this?