Ksoap2 android Outofmemory error for huge amount of data - android

I have searched lot of on google and found one solution. I have also tried that solution but still i got same error.Help me if anyone have solution for this problem. I got following error during webservice call.
'Caused by: java.lang.OutOfMemoryError
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:124)
at java.lang.StringBuilder.append(StringBuilder.java:271)
at org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1345)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:390)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:269)
at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:431)
at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:301)
at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:431)
at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:147)
at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
at org.ksoap2.transport.Transport.parseResponse(Transport.java:129)
at com.example.helper.HttpTransportSE.parseResponse(HttpTransportSE.java:338)
at com.example.helper.HttpTransportSE.call(HttpTransportSE.java:311)
at com.example.helper.HttpTransportSE.call(HttpTransportSE.java:125)
at com.example.helper.HttpTransportSE.call(HttpTransportSE.java:120)
at com.example.helper.HelperFunctions.getAccountList(HelperFunctions.java:293)
at com.example.profiler.SyncData$GetProfiler.doInBackground(SyncData.java:269)
at com.example.profiler.SyncData$GetProfiler.doInBackground(SyncData.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 3 more
java.lang.OutOfMemoryError
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:94)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:124)
at java.lang.StringBuilder.append(StringBuilder.java:271)
at org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1345)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:390)
at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:269)
at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:431)
at org.ksoap2.serialization.SoapSerializationEnvelope.readUnknown(SoapSerializationEnvelope.java:301)
at org.ksoap2.serialization.SoapSerializationEnvelope.read(SoapSerializationEnvelope.java:431)
at org.ksoap2.serialization.SoapSerializationEnvelope.parseBody(SoapSerializationEnvelope.java:147)
at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:140)
at org.ksoap2.transport.Transport.parseResponse(Transport.java:129)
at com.example.helper.HttpTransportSE.parseResponse(HttpTransportSE.java:338)
at com.example.helper.HttpTransportSE.call(HttpTransportSE.java:311)
at com.example.helper.HttpTransportSE.call(HttpTransportSE.java:125)
at com.example.helper.HttpTransportSE.call(HttpTransportSE.java:120)
at com.example.helper.HelperFunctions.getAccountList(HelperFunctions.java:293)
at com.example.profiler.SyncData$GetProfiler.doInBackground(SyncData.java:269)
at com.example.profiler.SyncData$GetProfiler.doInBackground(SyncData.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)'

Do u have used "bitmap" on your activity ?or load many data on your activity?
and u can use Bitmap.recycle();and System.gc(); at right time.
Hope that helps :).

Related

Want to crop video in 1:1 aspectration using ffmpeg but it gives error Working Directory: null Environment: null

I have used below command for crop video from originally captured by default camera. But when i was execute command it gives below error.
final String[] cmd={"-i", "/storage/emulated/0/DCIM/ZyfVideo/VID_20170914_153804.mp4","-s", "480x480" ,"-vf" ,"crop=480:480","setdar=1:1","setsar=1:1 ","/storage/emulated/0/Movies/SpoofApp/VDO_20170914_153811.mp4"};
Error Logcat :
09-14 15:38:11.874 3872-4039/com.spoof.app E/FFmpeg: Exception while trying to run: [Ljava.lang.String;#427ce088
java.io.IOException: Error running exec(). Command: [/data/data/com.spoof.app/files/ffmpeg, -i, /storage/emulated/0/DCIM/ZyfVideo/VID_20170914_153804.mp4, -s, 480x480, -vf, crop=480:480, setdar=1:1, setsar=1:1 , /storage/emulated/0/Movies/SpoofApp/VDO_20170914_153811.mp4] Working Directory: null Environment: null
at java.lang.ProcessManager.exec(ProcessManager.java:211)
at java.lang.Runtime.exec(Runtime.java:173)
at java.lang.Runtime.exec(Runtime.java:128)
at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:10)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38)
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.io.IOException: No such file or directory
at java.lang.ProcessManager.exec(Native Method)
at java.lang.ProcessManager.exec(ProcessManager.java:209)
at java.lang.Runtime.exec(Runtime.java:173) 
at java.lang.Runtime.exec(Runtime.java:128) 
at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:10) 
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38) 
at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10) 
at android.os.AsyncTask$2.call(AsyncTask.java:288) 
at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 
at java.lang.Thread.run(Thread.java:841) 
I have no such idea about ffmpeg but i can tell you about jCodec lib which is easy to use.
visit jcodec.org.
if you want to crop the video you will have to do below step in android or java.
1. get the frame from utility method from jcodec.
2. crop using Bitmap helper class.
3. pack in the mp4 format using jcodec utilty function.
if you are not able to do this kindly write a mail to me sunilgupta3443#gmail.com
I will help to make the crop video application for you in android.
Thank you

Use OkHttp to upload file but occur java.lang.IllegalStateException : closed at okio.RealBufferedSink.write(RealBufferedSink.java:44)

The issue is what the title said. It only occur sometimes and some phone. Hear is the log that I caught.
java.lang.IllegalStateException
closed
okio.RealBufferedSink.write(RealBufferedSink.java:44)
okio.ForwardingSink.write(ForwardingSink.java:35)
com.******.******.network.UploadRequestBody$1.write(UploadRequestBody.java:75)
okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
okio.RealBufferedSink.writeAll(RealBufferedSink.java:104)
com.squareup.okhttp.RequestBody$3.writeTo(RequestBody.java:118)
com.squareup.okhttp.MultipartBuilder$MultipartRequestBody.writeOrCountBytes(MultipartBuilder.java:277)
com.squareup.okhttp.MultipartBuilder$MultipartRequestBody.writeTo(MultipartBuilder.java:297)
com.******.******.network.UploadRequestBody.writeTo(UploadRequestBody.java:59)
com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:718)
com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:576)
com.squareup.okhttp.Call.getResponse(Call.java:287)
com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:243)
com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:205)
com.squareup.okhttp.Call.access$100(Call.java:35)
com.squareup.okhttp.Call$AsyncCall.execute(Call.java:171)
com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
java.lang.Thread.run(Thread.java:848)
Would you mind helping me and telling how to avoid it?
I find this at github issue
You can only call response.body().string() once.

java.io.FileNotFoundException in android URLConnection

I am facing the following exception when i try to call method on server, can any one tell me what is the problem ?
stacktrace
java.io.FileNotFoundException: https://services.q84sale.com/live/index.php/V1/Users/register
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:186)
com.android.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:246)
com.forsale.forsale.controller.manager.ForSaleNetworkManager.execute(ForSaleNetworkManager.java:116)
com.forsale.forsale.controller.manager.ForSaleServerManager$18.doInBackground(ForSaleServerManager.java:1423)
com.forsale.forsale.controller.manager.ForSaleServerManager$18.doInBackground(ForSaleServerManager.java:1399)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:848)
Too little information for right answer. Probably:
You specified an object with in your query that doesn't exist on server
You are using wrong method (GET, PUT) instead of POST
Server has some errors in its code
Add:
I noticed you are using .getInputStream() after receiving response code above 399. Check .getResponseCode() and then use .getErrorStream() instead

1895-1904/com.android.mms E/StrictMode﹕ is this my Bug?

Any help given at this stage will be appreciated, i have tried reading but now i am actually confused, The first time it was Calender i went and introduced an exception and that has gone away now i see it is mms How can i deal with this? any advice?
1895-1904/com.android.mms E/StrictMode﹕ A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'release' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:184)
at android.drm.DrmManagerClient.<init>(DrmManagerClient.java:258)
at com.google.android.mms.pdu.PduPersister.<init>(PduPersister.java:288)
at com.google.android.mms.pdu.PduPersister.getPduPersister(PduPersister.java:299)
at com.android.mms.transaction.TransactionService.onNewIntent(TransactionService.java:231)
at com.android.mms.transaction.TransactionService$ServiceHandler.handleMessage(TransactionService.java:633)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
1989-2046/com.android.email E/EmailServiceProxy﹕ RuntimeException when trying to unbind from service
java.lang.IllegalArgumentException: Service not registered: com.android.emailcommon.service.ServiceProxy$ProxyConnection#1d27587c
at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1029)
at android.app.ContextImpl.unbindService(ContextImpl.java:1808)
at android.content.ContextWrapper.unbindService(ContextWrapper.java:551)
at com.android.emailcommon.service.ServiceProxy$ProxyConnection$1.doInBackground(ServiceProxy.java:124)
at com.android.emailcommon.service.ServiceProxy$ProxyConnection$1.doInBackground(ServiceProxy.java:111)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
If you are building a custom ROM and are modifying the com.android.mms and com.android.email apps, then perhaps these are your issues.
Otherwise, they are issues for the developers of the com.android.mms and com.android.email apps.

unable to resolve host error with AWS Mobile Analytics on Android

I am trying to implement the starter code for AWS Mobile Analytics got from http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/analytics.html
I have everything setup along with Internet permission in manifest but I am still getting this error after all debugging and troubleshooting.
02-27 17:40:38.403 25639-25830/com.bluecolony.watchappstore I/AmazonHttpClient﹕ Unable to execute HTTP request: Unable to resolve host "mobileanalytics.us-east-1.": No address associated with hostname
java.net.UnknownHostException: Unable to resolve host "mobileanalytics.us-east-1.": No address associated with hostname
at java.net.InetAddress.lookupHostByName(InetAddress.java:424)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.amazonaws.org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278)
at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
at com.amazonaws.org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:400)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:243)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.invoke(AmazonMobileAnalyticsClient.java:313)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.putEvents(AmazonMobileAnalyticsClient.java:258)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.submitEvents(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.access$600(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient$3.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
at libcore.io.Posix.getaddrinfo(Native Method)
at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:61)
at java.net.InetAddress.lookupHostByName(InetAddress.java:405)
           
com.amazonaws.org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.resolveHostname(DefaultClientConnectionOperator.java:278)
at com.amazonaws.org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:162)
at com.amazonaws.org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
at com.amazonaws.org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at com.amazonaws.org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:400)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:243)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.invoke(AmazonMobileAnalyticsClient.java:313)
at com.amazonaws.services.mobileanalytics.AmazonMobileAnalyticsClient.putEvents(AmazonMobileAnalyticsClient.java:258)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.submitEvents(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient.access$600(Unknown Source)
at com.amazonaws.mobileconnectors.amazonmobileanalytics.internal.delivery.DefaultDeliveryClient$3.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
I have tried using ConnectivityManager and InetAddress.getByName("google.com").isReachable(3) to confirm that my code is able to access internet.
My assumption so far is that somehow hostname which is called is wrong. it should be "mobileanalytics.us-east-1.amazonaws.com" instead of "mobileanalytics.us-east-1." . Otherwise it can be a firewall issue or with https , which I have to explore further. I am connected with wifi on mobile.
Any pointers to help ?
Looks like this was a known bug with the AWS Mobile SDK v2.1.9.
Reading through #Yangfan's comment looks like this has been addressed in version 2.1.10
http://aws.amazon.com/releasenotes/3841134019807789

Categories

Resources