I'm trying to accomplish Reading and Creating folders in the operations Own Cloud server through AsyncTask, login to the server with my credentials is done successfully, but when trying to create folders and read the following errors in the log is described below, which would be the possible reason for the error?
04-07 15:45:24.500: I/OwnCloud(31352): Sending File
04-07 15:45:24.510: I/OwnCloud(31352): Start Read Remote Folder
04-07 15:45:24.620: I/ReadRemoteFolderOperation(31352): Synchronized /: Operation finished with HTTP status code 207 (success)
04-07 15:45:24.630: I/OwnCloud(31352): Sending File
04-07 15:45:24.630: W/dalvikvm(31352): threadid=11: thread exiting with uncaught exception (group=0x40ffe438)
04-07 15:45:24.640: E/AndroidRuntime(31352): FATAL EXCEPTION: AsyncTask #1
04-07 15:45:24.640: E/AndroidRuntime(31352): java.lang.RuntimeException: An error occured while executing doInBackground()
04-07 15:45:24.640: E/AndroidRuntime(31352): at android.os.AsyncTask$3.done(AsyncTask.java:299)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-07 15:45:24.640: E/AndroidRuntime(31352): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.lang.Thread.run(Thread.java:856)
04-07 15:45:24.640: E/AndroidRuntime(31352): Caused by: java.lang.ArrayIndexOutOfBoundsException: length=5; index=5
04-07 15:45:24.640: E/AndroidRuntime(31352): at com.prologica.procamera.MainActivity$UploadPhotos.SendFolders(MainActivity.java:127)
04-07 15:45:24.640: E/AndroidRuntime(31352): at com.prologica.procamera.MainActivity$UploadPhotos.doInBackground(MainActivity.java:95)
04-07 15:45:24.640: E/AndroidRuntime(31352): at com.prologica.procamera.MainActivity$UploadPhotos.doInBackground(MainActivity.java:1)
04-07 15:45:24.640: E/AndroidRuntime(31352): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-07 15:45:24.640: E/AndroidRuntime(31352): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
04-07 15:45:24.640: E/AndroidRuntime(31352): ... 5 more
You have an array out of bound in com.prologica.procamera.MainActivity UploadPhotos.SendFolders(MainActivity.java:127). Check line 127 in MainActivity to make sure you are not going out of bounds. According to the log, the length is 5 and you are trying to access index 5(which does not exist)
Related
My facebook login application fails with the following runtime error:
07-31 12:47:10.195 1309-1316/com.android.quicksearchbox E/jdwp﹕ Failed writing handshake bytes: Broken pipe (-1 of 14)
07-31 12:47:11.004 1341-1358/com.example.apurva.myapplication E/ActivityThread﹕ Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
07-31 12:47:11.094 1341-1360/com.example.apurva.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #2
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:781)
at com.facebook.internal.Utility.queryAppSettings(Utility.java:802)
at com.facebook.login.widget.LoginButton$1.doInBackground(LoginButton.java:502)
at com.facebook.login.widget.LoginButton$1.doInBackground(LoginButton.java:499)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
A few pointers on what I have done till now:
1)Followed all the requirements in Facebook's Getting Started post.
2)Added the meta-data to the XML.
3)Added the key-hash to facebook
If you see any particular files that might be causing the problem and want to see it before answering, do let me know.
I have two activities that both make different http requests to my server when started.
When I switch back and forth between them the responses start to have some delay because they get queued up on top of eachother.
I would like to empty and abort this connections and just keep the latest one.
I tried
httpClient.getConnectionManager().shutdown();
but it throws
05-14 08:20:51.137 12627-12997/com.tesis.restapp E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #2
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.IllegalStateException: Manager is shut down.
at org.apache.http.impl.conn.SingleClientConnManager.assertStillUp(SingleClientConnManager.java:175)
at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:213)
at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:191)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:326)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:580)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:512)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:490)
at support.JSONParser.makeHttpRequest(JSONParser.java:96)
at fragments.MainFragment$FetchOrders.doInBackground(MainFragment.java:150)
at fragments.MainFragment$FetchOrders.doInBackground(MainFragment.java:129)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)...
Any other ideas? Thanks
Just cancelling the AsyncTask that carried out the HttpRequest did the trick!
I run some DB stuff inside an asynctask that runs inside a runnable via handler.postdelayed(r, 30000). It gets repeated (as you can see, every 30 seconds).
Sometimes, not everytime, my app is crashing. Below is the logcat.
09-24 18:28:52.813: W/dalvikvm(6194): threadid=12: thread exiting with uncaught exception (group=0x40daf1f8)
09-24 18:28:52.823: E/AndroidRuntime(6194): FATAL EXCEPTION: AsyncTask #2
09-24 18:28:52.823: E/AndroidRuntime(6194): java.lang.RuntimeException: An error occured while executing doInBackground()
09-24 18:28:52.823: E/AndroidRuntime(6194): at android.os.AsyncTask$3.done(AsyncTask.java:278)
09-24 18:28:52.823: E/AndroidRuntime(6194): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
09-24 18:28:52.823: E/AndroidRuntime(6194): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
09-24 18:28:52.823: E/AndroidRuntime(6194): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
09-24 18:28:52.823: E/AndroidRuntime(6194): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
09-24 18:28:52.823: E/AndroidRuntime(6194): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
09-24 18:28:52.823: E/AndroidRuntime(6194): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
09-24 18:28:52.823: E/AndroidRuntime(6194): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
09-24 18:28:52.823: E/AndroidRuntime(6194): at java.lang.Thread.run(Thread.java:856)
09-24 18:28:52.823: E/AndroidRuntime(6194): Caused by: java.lang.IllegalStateException: database /data/data/com.myApp/databases/mydb.db (conn# 0) already closed
09-24 18:28:52.823: E/AndroidRuntime(6194): at android.database.sqlite.SQLiteDatabase.verifyDbIsOpen(SQLiteDatabase.java:2100)
09-24 18:28:52.823: E/AndroidRuntime(6194): at android.database.sqlite.SQLiteDatabase.lock(SQLiteDatabase.java:418)
09-24 18:28:52.823: E/AndroidRuntime(6194): at android.database.sqlite.SQLiteDatabase.lock(SQLiteDatabase.java:405)
09-24 18:28:52.823: E/AndroidRuntime(6194): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:79)
09-24 18:28:52.823: E/AndroidRuntime(6194): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164)
09-24 18:28:52.823: E/AndroidRuntime(6194): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156)
09-24 18:28:52.823: E/AndroidRuntime(6194): at com.myApp.DbAllHelper.dbMethod1(DbAllHelper.java:273)
09-24 18:28:52.823: E/AndroidRuntime(6194): at com.myApp.DbAllHelper.dbMethod2(DbAllHelper.java:582)
09-24 18:28:52.823: E/AndroidRuntime(6194): at com.myApp.MainActivity$checkToInternetOnly.doInBackground(MainActivity.java:278)
09-24 18:28:52.823: E/AndroidRuntime(6194): at com.myApp.MainActivity$checkToInternetOnly.doInBackground(MainActivity.java:1)
09-24 18:28:52.823: E/AndroidRuntime(6194): at android.os.AsyncTask$2.call(AsyncTask.java:264)
09-24 18:28:52.823: E/AndroidRuntime(6194): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
You get somewhere along the logcat an IllegalStateException because the database is already closed. Make sure your background tasks are canceled before you close the database, which is done latest in onDestroy of your Activity.
09-24 18:28:52.823: E/AndroidRuntime(6194): Caused by: java.lang.IllegalStateException: database /data/data/com.myApp/databases/mydb.db (conn# 0) already closed
Are you sure you did not close a Cursor by accident before usage. That or is the asynctask by any chance started twice at some point?
Whatever the reason is, it seems the code at some point is trying to access a closed Cursor.
I have a number of smartwatch apps. They all behaive as expected for me but I am getting intermittent crash reports from ACRA in the smartwatch library code. No reference to anything in my code so I don't know if there is anything I can do about the issue.
Anyone from Sony got any ideas?
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.lang.NullPointerException
at android.database.AbstractCursor.getColumnIndex(AbstractCursor.java:249)
at android.database.CursorWrapper.getColumnIndex(CursorWrapper.java:73)
at com.sonyericsson.extras.liveware.extension.util.e.a(SourceFile:263)
at com.sonyericsson.extras.liveware.extension.util.c.e.c(SourceFile:154)
at com.sonyericsson.extras.liveware.extension.util.c.e.b(SourceFile:116)
at com.sonyericsson.extras.liveware.extension.util.c.e.doInBackground(SourceFile:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 5 more
java.lang.NullPointerException
at android.database.AbstractCursor.getColumnIndex(AbstractCursor.java:249)
at android.database.CursorWrapper.getColumnIndex(CursorWrapper.java:73)
at com.sonyericsson.extras.liveware.extension.util.e.a(SourceFile:263)
at com.sonyericsson.extras.liveware.extension.util.c.e.c(SourceFile:154)
at com.sonyericsson.extras.liveware.extension.util.c.e.b(SourceFile:116)
at com.sonyericsson.extras.liveware.extension.util.c.e.doInBackground(SourceFile:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
I would post this as comment, but I don't have the reputation...
How many different phones are you testing with? Hopefully, you have a few, from few different makers (i.e. they're not only Samsung, for example). I've seen something similar happen to my apps running on a Sony phone, and not on an LG.
I know that the JDBC is best used with a low latency high-bandwidth connection. and it is better to use a php service.
Thing is am developing a Restaurant menu app that should retrieve data from a db located on a server. using the Samsung galaxy tab2 7inch as the target device and having a stable wireless connection with high bandwidth.My first attempt was to have a java server running on the same machine that have the db and have alot of threads that will retrieve data and send them to android device over a tcp socket.
This implementation resulted in high cpu usage both on the host machine and the android device since i have a lot of threads working in the background.
I though to give JDBC a try since the environment enable me to use such implementation. but so far not successful with connecting to the DB.even tho i have internet permission on the android application Manifest.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try {
Class.forName("com.mysql.jdbc.Driver");
this.setTitle("Driver started ");
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://192.168.1.3/cafe", "root", "1234");
this.setTitle("Connected to db");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
this code will give me the following error
04-07 15:22:41.222: W/System.err(11318): com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
04-07 15:22:41.222: W/System.err(11318): The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
04-07 15:22:41.238: W/System.err(11318): at java.lang.reflect.Constructor.constructNative(Native Method)
04-07 15:22:41.238: W/System.err(11318): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-07 15:22:41.238: W/System.err(11318): at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
04-07 15:22:41.238: W/System.err(11318): at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1121)
04-07 15:22:41.238: W/System.err(11318): at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:355)
04-07 15:22:41.238: W/System.err(11318): at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2479)
04-07 15:22:41.238: W/System.err(11318): at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2516)
04-07 15:22:41.245: W/System.err(11318): at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2301)
04-07 15:22:41.245: W/System.err(11318): at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
04-07 15:22:41.245: W/System.err(11318): at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
04-07 15:22:41.245: W/System.err(11318): at java.lang.reflect.Constructor.constructNative(Native Method)
04-07 15:22:41.245: W/System.err(11318): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-07 15:22:41.245: W/System.err(11318): at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
04-07 15:22:41.245: W/System.err(11318): at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
04-07 15:22:41.245: W/System.err(11318): at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:317)
04-07 15:22:41.245: W/System.err(11318): at java.sql.DriverManager.getConnection(DriverManager.java:175)
04-07 15:22:41.245: W/System.err(11318): at java.sql.DriverManager.getConnection(DriverManager.java:209)
04-07 15:22:41.245: W/System.err(11318): at com.example.anndroidjdbc.MainActivity.onCreate(MainActivity.java:23)
04-07 15:22:41.245: W/System.err(11318): at android.app.Activity.performCreate(Activity.java:4465)
04-07 15:22:41.245: W/System.err(11318): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
04-07 15:22:41.245: W/System.err(11318): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
04-07 15:22:41.245: W/System.err(11318): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
04-07 15:22:41.245: W/System.err(11318): at android.app.ActivityThread.access$600(ActivityThread.java:128)
04-07 15:22:41.245: W/System.err(11318): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
04-07 15:22:41.245: W/System.err(11318): at android.os.Handler.dispatchMessage(Handler.java:99)
04-07 15:22:41.245: W/System.err(11318): at android.os.Looper.loop(Looper.java:137)
04-07 15:22:41.253: W/System.err(11318): at android.app.ActivityThread.main(ActivityThread.java:4514)
04-07 15:22:41.253: W/System.err(11318): at java.lang.reflect.Method.invokeNative(Native Method)
04-07 15:22:41.253: W/System.err(11318): at java.lang.reflect.Method.invoke(Method.java:511)
04-07 15:22:41.253: W/System.err(11318): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
04-07 15:22:41.253: W/System.err(11318): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
04-07 15:22:41.253: W/System.err(11318): at dalvik.system.NativeStart.main(Native Method)
04-07 15:22:41.253: W/System.err(11318): Caused by: java.net.SocketException: android.os.NetworkOnMainThreadException
04-07 15:22:41.253: W/System.err(11318): at com.mysql.jdbc.StandardSocketFactory.unwrapExceptionToProperClassAndThrowIt(StandardSocketFactory.java:410)
04-07 15:22:41.253: W/System.err(11318): at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:271)
04-07 15:22:41.253: W/System.err(11318): at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:305)
04-07 15:22:41.253: W/System.err(11318): ... 27 more
As for the PHP web-service i really dont know anything how to use it or setup it. what do you guys think i should do ? continue with my first implementation or switch to a direct approach from the android device to the mysql db using a php service .
Sorry This is considered a duplicate . i just want your opinion about the problem am having and if someone could point me to a better approach or can help with the error from the JDBC i will be thankful.
Only yesterday did another user ask the same thing and there are some good answers to be found on that question - JDBC vs Web Service for Android
As for the PHP web-service i really dont know anything how to use it or setup it.
I guess you're gonna have to take a 101 on that.