I am new to Android Development. I install CouchDB on the server and created a user. I use following code in my app.
#ReportsCrashes (
formKey = "",
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
formUri = "localhost:5984/acra-myapp/_design/acra-storage/_update/report",
formUriBasicAuthLogin = "admin",
formUriBasicAuthPassword = "admin"
)
when i run my app from android device it give me following error:
02-04 12:46:26.606: E/ACRA(348): Failed to send crash report for 1391497913000-approved.stacktrace
02-04 12:46:26.606: E/ACRA(348): org.acra.sender.ReportSenderException: Error while sending JSON report via Http PUT
02-04 12:46:26.606: E/ACRA(348): at org.acra.sender.HttpSender.send(HttpSender.java:228)
02-04 12:46:26.606: E/ACRA(348): at org.acra.SendWorker.sendCrashReport(SendWorker.java:179)
02-04 12:46:26.606: E/ACRA(348): at org.acra.SendWorker.checkAndSendReports(SendWorker.java:141)
02-04 12:46:26.606: E/ACRA(348): at org.acra.SendWorker.run(SendWorker.java:77)
02-04 12:46:26.606: E/ACRA(348): Caused by: org.apache.http.conn.HttpHostConnectException: Connection to `*` refused
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:183)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:365)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
02-04 12:46:26.606: E/ACRA(348): at org.acra.util.HttpRequest.send(HttpRequest.java:152)
02-04 12:46:26.606: E/ACRA(348): at org.acra.sender.HttpSender.send(HttpSender.java:225)
02-04 12:46:26.606: E/ACRA(348): ... 3 more
02-04 12:46:26.606: E/ACRA(348): Caused by: java.net.ConnectException: failed to connect to after 3000ms: isConnected failed: ECONNREFUSED (Connection refused)
02-04 12:46:26.606: E/ACRA(348): at libcore.io.IoBridge.isConnected(IoBridge.java:250)
02-04 12:46:26.606: E/ACRA(348): at libcore.io.IoBridge.connectErrno(IoBridge.java:178)
02-04 12:46:26.606: E/ACRA(348): at libcore.io.IoBridge.connect(IoBridge.java:112)
02-04 12:46:26.606: E/ACRA(348): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
02-04 12:46:26.606: E/ACRA(348): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
02-04 12:46:26.606: E/ACRA(348): at java.net.Socket.connect(Socket.java:859)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
02-04 12:46:26.606: E/ACRA(348): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
02-04 12:46:26.606: E/ACRA(348): ... 10 more
02-04 12:46:26.606: E/ACRA(348): Caused by: libcore.io.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
02-04 12:46:26.606: E/ACRA(348): at libcore.io.IoBridge.isConnected(IoBridge.java:234)
Can't seem to figure out this error.Please help me.
You access your computer's localhost as 10.0.2.2 from emulator. more details
http://developer.android.com/guide/appendix/faq/commontasks.html#localhostalias
try below code
formKey = "",
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
formUri = "10.0.2.2:5984/acra-mediwatch/_design/acra-storage/_update/report",
formUriBasicAuthLogin = "admin",
formUriBasicAuthPassword = "admin"
Add the INTERNET permission to your manifest file.
You have to add this line:
<uses-permission android:name="android.permission.INTERNET" />
outside the application tag in your AndroidManifest.xml
"Connection refused" means that the host could be reached but there wasn't anything listening in the target port. So, first make sure you have your server running on 208.109.91.98 port 5984.
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.
My app that is using Retrofit (v1.6.1) to connect to REST web services cannot connect to my local web server (running on localhost), this is the error I am getting.
This is inside Nexus4 (v4.3) emulator, I am using Android Studio for development and I have added android.permission.INTERNET & android.permission.ACCESS_NETWORK_STATE permissions in manifest file.
The error says its waited for 15s but it does not, it errors out right away.
07-13 15:57:53.947 820-840/it.test.android.app.activity D/Retrofit﹕ ---> HTTP POST http://localhost:3000/app/auth/signin
07-13 15:57:54.132 820-840/it.test.android.app.activity D/Retrofit﹕ Content-Type: application/json; charset=UTF-8
07-13 15:57:54.132 820-840/it.test.android.app.activity D/Retrofit﹕ Content-Length: 44
07-13 15:57:54.157 820-840/it.test.android.app.activity D/Retrofit﹕ {"auth":{"email":"steve","password":"pass"}}
07-13 15:57:54.387 820-840/it.test.android.app.activity D/Retrofit﹕ ---> END HTTP (44-byte body)
07-13 15:57:54.657 820-840/it.test.android.app.activity D/Retrofit﹕ ---- ERROR http://localhost:3000/app/auth/signin
07-13 15:57:54.857 820-840/it.test.android.app.activity D/Retrofit﹕ java.net.ConnectException: failed to connect to localhost/127.0.0.1 (port 3000) after 15000ms: isConnected failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.isConnected(IoBridge.java:223)
at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:842)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)
at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197)
at retrofit.client.UrlConnectionClient.prepareRequest(UrlConnectionClient.java:68)
at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:37)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.ErrnoException: isConnected failed: ECONNREFUSED (Connection refused)
at libcore.io.IoBridge.isConnected(IoBridge.java:208)
at libcore.io.IoBridge.connectErrno(IoBridge.java:161)
at libcore.io.IoBridge.connect(IoBridge.java:112)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
at java.net.Socket.connect(Socket.java:842)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340)
at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316)
at libcore.net.http.HttpEngine.connect(HttpEngine.java:311)
at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290)
at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240)
at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:81)
at libcore.net.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:197)
at retrofit.client.UrlConnectionClient.prepareRequest(UrlConnectionClient.java:68)
at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:37)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:841)
07-13 15:57:54.857 820-840/it.test.android.app.activity D/Retrofit﹕ ---- END ERROR
On your phone connecting to localhost:3000 means "connect to port 3000 on local network interface" - which is local interface of the phone, not the port 3000 of the PC to which your phone is connected. There is nothing listening on port 3000 on the phone, so you get connection refused error.
Whould you're trying to do is (probably, hard to guess without more information) is to connect from the phone to port 3000 on you PC. So you should change the address you're connecting to from localhost to address of the PC. In case of emulator that would be 10.0.2.2 (which is localhost of the PC). See networking information for reference.
I solved the issue, need to use 10.0.2.2 instead of localhost to connect to my local server.
Found it here - http://developer.android.com/tools/devices/emulator.html#networkaddresses
I'm working on an app which reads a .txt file that is stored in the SD card (inside /data/local). The problem I have is that it seems that it can access to the file path, but it can't access the file itself (although it has read and write permissions), it throws a FileNotFoundException.
Here I leave you the code and the log:
String ruta="/data/local/textojson.txt";
System.out.println(ruta);
String cadena="", Jsontx="";
File sd = Environment.getExternalStorageDirectory();
File f = new File(sd.getAbsolutePath(), ruta);
System.out.println(f);
BufferedReader entrada;
try
{
entrada = new BufferedReader(new FileReader(f));
System.out.println(entrada);
try
{
while((cadena=entrada.readLine())!=null)
{
Jsontx=cadena;
}
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
I've added the READ_EXTERNAL_STORAGE permissions to the manifest, and the file really exists in that directory.
02-04 19:26:40.535: E/Trace(20167): error opening trace file: No such file or directory (2)
02-04 19:26:41.055: I/System.out(20167): /data/local/textojson.txt
02-04 19:26:41.066: I/System.out(20167): /mnt/sdcard/data/local/textojson.txt
02-04 19:26:41.066: W/System.err(20167): java.io.FileNotFoundException: /mnt/sdcard/data/local/textojson.txt: open failed: ENOENT (No such file or directory)
02-04 19:26:41.066: W/System.err(20167): at libcore.io.IoBridge.open(IoBridge.java:416)
02-04 19:26:41.075: W/System.err(20167): at java.io.FileInputStream.<init>(FileInputStream.java:78)
02-04 19:26:41.075: W/System.err(20167): at java.io.FileReader.<init>(FileReader.java:42)
02-04 19:26:41.075: W/System.err(20167): at es.example.jsonarchivo.Adapter.<init>(Adapter.java:47)
02-04 19:26:41.075: W/System.err(20167): at es.example.jsonarchivo.MainActivity.onCreate(MainActivity.java:27)
02-04 19:26:41.075: W/System.err(20167): at android.app.Activity.performCreate(Activity.java:5008)
02-04 19:26:41.085: W/System.err(20167): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-04 19:26:41.085: W/System.err(20167): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 19:26:41.085: W/System.err(20167): at android.os.Looper.loop(Looper.java:137)
02-04 19:26:41.085: W/System.err(20167): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-04 19:26:41.095: W/System.err(20167): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 19:26:41.105: W/System.err(20167): at java.lang.reflect.Method.invoke(Method.java:511)
02-04 19:26:41.105: W/System.err(20167): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-04 19:26:41.105: W/System.err(20167): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-04 19:26:41.105: W/System.err(20167): at dalvik.system.NativeStart.main(Native Method)
02-04 19:26:41.105: W/System.err(20167): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
02-04 19:26:41.116: W/System.err(20167): at libcore.io.Posix.open(Native Method)
02-04 19:26:41.116: W/System.err(20167): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
02-04 19:26:41.116: W/System.err(20167): at libcore.io.IoBridge.open(IoBridge.java:400)
02-04 19:26:41.125: W/System.err(20167): ... 18 more
02-04 19:26:41.125: D/AndroidRuntime(20167): Shutting down VM
02-04 19:26:41.125: W/dalvikvm(20167): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
02-04 19:26:41.145: E/AndroidRuntime(20167): FATAL EXCEPTION: main
02-04 19:26:41.145: E/AndroidRuntime(20167): java.lang.RuntimeException: Unable to start activity ComponentInfo{es.example.jsonarchivo/es.example.jsonarchivo.MainActivity}: java.lang.NullPointerException
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.os.Handler.dispatchMessage(Handler.java:99)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.os.Looper.loop(Looper.java:137)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.main(ActivityThread.java:4745)
02-04 19:26:41.145: E/AndroidRuntime(20167): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 19:26:41.145: E/AndroidRuntime(20167): at java.lang.reflect.Method.invoke(Method.java:511)
02-04 19:26:41.145: E/AndroidRuntime(20167): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-04 19:26:41.145: E/AndroidRuntime(20167): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-04 19:26:41.145: E/AndroidRuntime(20167): at dalvik.system.NativeStart.main(Native Method)
02-04 19:26:41.145: E/AndroidRuntime(20167): Caused by: java.lang.NullPointerException
02-04 19:26:41.145: E/AndroidRuntime(20167): at com.android.internal.os.LoggingPrintStream.println(LoggingPrintStream.java:298)
02-04 19:26:41.145: E/AndroidRuntime(20167): at es.example.jsonarchivo.Adapter.<init>(Adapter.java:70)
02-04 19:26:41.145: E/AndroidRuntime(20167): at es.example.jsonarchivo.MainActivity.onCreate(MainActivity.java:27)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.Activity.performCreate(Activity.java:5008)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
02-04 19:26:41.145: E/AndroidRuntime(20167): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
02-04 19:26:41.145: E/AndroidRuntime(20167): ... 11 more
02-04 19:31:41.224: I/Process(20167): Sending signal. PID: 20167 SIG: 9
I hope I have explained it well, my mother tongue isn't english.
To recap in an answer,
java.io.FileNotFoundException: /mnt/sdcard/data/local/textojson.txt: open failed: ENOENT (No such file or directory)
means that the file does not exist. This can be verified with f.exists()
If the problem was permissions you should get open failed: EACCES (Permission denied)
I am using the admob sdk (6.1.0) to show two banners on top of my custom ListFragments with this code in each fragment at onActivityCreated():
LinearLayout adLayout = new LinearLayout(getActivity());
adView = new AdView(getActivity(), AdSize.SMART_BANNER, "xxxxxxxxxxxxx");
adView.loadAd(new AdRequest());
adLayout.addView(adView);
getListView().addHeaderView(adLayout);
everything works fine on my old LG Optimus 2X on Ginger Bread but now i have a Samsung Galaxy S3 on Jelly Bean and my ads won't show up anymore!
I'm getting this error:
09-24 23:07:35.661: I/Ads(24043): Refreshing ad.
09-24 23:07:35.691: I/webclipboard(24043): clipservice: android.sec.clipboard.ClipboardExManager#42a88b90
09-24 23:07:35.696: V/webkit(24043): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {42cc0c00}
09-24 23:07:35.726: I/Ads(24043): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"kw":[],"preqs":2,"session_id":"16934128083720156505","u_sd":2,"seq_num":"3","slotname":"xxxxxxxxxxxx","u_w":360,"msid":"com.thiost.android.twire","js":"afma-sdk-a-v6.1.0","toar":2,"mv":"8014017.com.android.vending","isu":"605557A27D3A2A6A54663D68CFF48311","cipa":0,"format":"320x50_mb","net":"wi","app_name":"903.android.com.thiost.android.twire","hl":"nl","u_h":640,"carrier":"20404","ptime":120187,"u_audio":3});</script></head><body></body></html>
09-24 23:07:35.916: E/Ads(24043): JS: Uncaught ReferenceError: AFMA_getSdkConstants is not defined (about:blank:1)
09-24 23:07:35.916: E/Web Console(24043): Uncaught ReferenceError: AFMA_getSdkConstants is not defined:1
09-24 23:08:35.716: I/Ads(24043): AdLoader timed out after 60000ms while getting the URL.
09-24 23:08:35.721: D/webviewglue(24043): nativeDestroy view: 0x531a3420
09-24 23:08:35.726: I/Ads(24043): onFailedToReceiveAd(A network error occurred.)
09-24 23:09:35.786: I/Ads(24043): Refreshing ad.
09-24 23:09:35.811: I/webclipboard(24043): clipservice: android.sec.clipboard.ClipboardExManager#42a88b90
09-24 23:09:35.821: V/webkit(24043): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {42d893c0}
09-24 23:09:35.851: I/Ads(24043): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"kw":[],"preqs":3,"session_id":"16934128083720156505","u_sd":2,"seq_num":"4","slotname":"xxxxxxxxxxxx","u_w":360,"msid":"com.thiost.android.twire","js":"afma-sdk-a-v6.1.0","toar":3,"mv":"8014017.com.android.vending","isu":"605557A27D3A2A6A54663D68CFF48311","cipa":0,"format":"320x50_mb","net":"wi","app_name":"903.android.com.thiost.android.twire","hl":"nl","u_h":640,"carrier":"20404","ptime":240317,"u_audio":3});</script></head><body></body></html>
09-24 23:09:35.881: D/dalvikvm(24043): GC_CONCURRENT freed 1150K, 26% free 14863K/20039K, paused 6ms+5ms, total 50ms
09-24 23:09:35.996: E/Ads(24043): JS: Uncaught ReferenceError: AFMA_getSdkConstants is not defined (about:blank:1)
09-24 23:09:35.996: E/Web Console(24043): Uncaught ReferenceError: AFMA_getSdkConstants is not defined:1
I'm only getting this error when the app loads an add for the first time on a WiFi connection. All the other times on WiFi it gives me this error:
09-25 17:29:37.600: W/Ads(23165): IOException connecting to ad url.
09-25 17:29:37.600: W/Ads(23165): java.net.ConnectException: failed to connect to googleads.g.doubleclick.net/127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused)
09-25 17:29:37.600: W/Ads(23165): at libcore.io.IoBridge.connect(IoBridge.java:114)
09-25 17:29:37.600: W/Ads(23165): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
09-25 17:29:37.600: W/Ads(23165): at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
09-25 17:29:37.600: W/Ads(23165): at java.net.Socket.connect(Socket.java:842)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:76)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:341)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpConnection.connect(HttpConnection.java:128)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:315)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpEngine.connect(HttpEngine.java:310)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:289)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:239)
09-25 17:29:37.600: W/Ads(23165): at libcore.net.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:80)
09-25 17:29:37.600: W/Ads(23165): at com.google.ads.internal.f.b(SourceFile:459)
09-25 17:29:37.600: W/Ads(23165): at com.google.ads.internal.f.run(SourceFile:430)
09-25 17:29:37.600: W/Ads(23165): at java.lang.Thread.run(Thread.java:856)
09-25 17:29:37.600: W/Ads(23165): Caused by: libcore.io.ErrnoException: connect failed: ECONNREFUSED (Connection refused)
09-25 17:29:37.600: W/Ads(23165): at libcore.io.Posix.connect(Native Method)
09-25 17:29:37.600: W/Ads(23165): at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:85)
09-25 17:29:37.600: W/Ads(23165): at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
09-25 17:29:37.600: W/Ads(23165): at libcore.io.IoBridge.connect(IoBridge.java:112)
09-25 17:29:37.600: W/Ads(23165): ... 16 more
It doesn't give errors on a mobile internet connection...
I figured out what the problem was.
I had flashed a new rom that installed a new hosts file wich was blocking my ads...
After deleting the hosts file the ads were displayed
i want to play mp3 file which is streamed mp3 file. i tried below link example
http://blog.pocketjourney.com/2008/04/04/tutorial-custom-media-streaming-for-androids-mediaplayer/
but the bellow error is coming
02-04 20:22:48.960: ERROR/PlayerDriver(31): Command PLAYER_PREPARE completed with an error or info PVMFErrResource
02-04 20:22:48.970: ERROR/MediaPlayer(425): error (1, -17)
02-04 20:22:48.989: WARN/PlayerDriver(31): PVMFInfoErrorHandlingComplete
02-04 20:22:49.089: DEBUG/dalvikvm(425): GC freed 4622 objects / 982864 bytes in 120ms
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): Error updating to newly loaded content.
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): java.io.IOException: Prepare failed.: status=0x1
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.media.MediaPlayer.prepare(Native Method)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer.createMediaPlayer(StreamingMediaPlayer.java:210)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer.transferBufferToMediaPlayer(StreamingMediaPlayer.java:239)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer.access$3(StreamingMediaPlayer.java:219)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.Boodang.StreamingMediaPlayer$2.run(StreamingMediaPlayer.java:160)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.os.Handler.handleCallback(Handler.java:587)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.os.Handler.dispatchMessage(Handler.java:92)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.os.Looper.loop(Looper.java:123)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at android.app.ActivityThread.main(ActivityThread.java:4363)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at java.lang.reflect.Method.invokeNative(Native Method)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at java.lang.reflect.Method.invoke(Method.java:521)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-04 20:22:49.350: ERROR/com.Boodang.StreamingMediaPlayer(425): at dalvik.system.NativeStart.main(Native Method)
so please tell me what i will do and i hope there is better way to do this one . so please tell me how to stream the mp3 file and play the mp3 file.
Thank you.
Best Regards.
First, that blog post is nearly three years old. Never use Android blog posts from that long ago.
Second, at least through Android 2.2, streaming MP3 files was not supported over RTSP. I think it works over HTTP.
Beyond that, make sure the URL you are using actually is reachable from your device or emulator. For example, you need the INTERNET permission in your app, your emulator needs to have Internet access, etc.
In the future, you might consider supplying source code, as a stack trace alone is usually insufficient to get assistance from anyone.