I have a news app that gets its content via JSON and at times it parses very large strings. I have an object that holds all the article's data which is then saved to a database.
However, at times, I get an out of memory exception with the object class. The following is the logcat:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:137)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
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)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 230 byte allocation with 96 free bytes and 96B until OOM
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:163)
at java.lang.StringBuilder.append(StringBuilder.java:288)
at com.android.internal.os.LoggingPrintStream.append(LoggingPrintStream.java:333)
at com.android.internal.os.LoggingPrintStream.append(LoggingPrintStream.java:36)
at java.lang.Throwable.printStackTrace(Throwable.java:315)
at java.lang.Throwable.printStackTrace(Throwable.java:282)
at java.lang.Throwable.printStackTrace(Throwable.java:236)
at com.radioafrica.mpasho.object.Article.(Article.java:31)
at com.radioafrica.mpasho.loader.FeedsLoader.loadInBackground(FeedsLoader.java:50)
at com.radioafrica.mpasho.loader.FeedsLoader.loadInBackground(FeedsLoader.java:24)
at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:242)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:51)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:40)
at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:123)
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:818)
The error occurs when i try to load the data via an asynctaskloader before passing the data to the adapter.
Related
I am using the docx4j android code from this link.
https://github.com/plutext/AndroidDocxToHtml/tree/master/libs
I am getting this error. Anyone has idea , i am not able to figure it out.
java.lang.RuntimeException:
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
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)
Caused by: java.lang.Error:
at ae.com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.init(RuntimeBuiltinLeafInfoImpl.java:906)
at ae.com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(RuntimeBuiltinLeafInfoImpl.java:900)
at ae.com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(RuntimeTypeInfoSetImpl.java:65)
at ae.com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:134)
at ae.com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:86)
at ae.com.sun.xml.bind.v2.model.impl.ModelBuilder.<init>(ModelBuilder.java:156)
at ae.com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:94)
at ae.com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:451)
at ae.com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:299)
at ae.com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:142)
at ae.com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1164)
at ae.com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:146)
at ae.com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:237)
at java.lang.reflect.Method.invoke(Native Method:0)
at java.lang.reflect.Method.invoke(Method.java:372)
at ae.javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:186)
at ae.javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:146)
at ae.javax.xml.bind.ContextFinder.find(ContextFinder.java:348)
at ae.javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:446)
at ae.javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:409)
at org.docx4j.jaxb.NamespacePrefixMapperUtils.getPrefixMapper(NamespacePrefixMapperUtils.java:47)
at org.docx4j.jaxb.Context.<clinit>(Context.java:67)
at org.docx4j.openpackaging.contenttype.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:651)
at org.docx4j.openpackaging.io.LoadFromZipNG.process(LoadFromZipNG.java:206)
at org.docx4j.openpackaging.io.LoadFromZipNG.get(LoadFromZipNG.java:193)
My app has started crashing during the google sign in process.
It wasn't crashing like this before.
Could it be connected to changing the Google Play services version?
What else could cause this crash?
I was able to stop it before by delaying when I implement my OneSignal initialization in the Application class. But, I am not sure how they are connected and have only come across the connection because of trial and error. Changing my OneSignal implementation doesn't seem like a proper solution as it sidesteps a problem that wasn't occurring before and may occur again if I don't find a more specific cause for it.
Also, the crash doesn't always occur during the sign in process.
The main clues from the logcat seem to be:
An error occurred while executing doInBackground()
Caused by: java.util.ConcurrentModificationException
at com.google.android.gms.auth.api.signin.internal.zzb.zzafx(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzb.loadInBackground(Unknown Source)
Here is the full logcat:
UncaughtException: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:142)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
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)
Caused by: java.util.ConcurrentModificationException
at java.util.WeakHashMap$HashIterator.next(WeakHashMap.java:165)
at com.google.android.gms.auth.api.signin.internal.zzb.zzafx(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzb.loadInBackground(Unknown Source)
at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:296)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:54)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:42)
at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:128)
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:818) `11-11 00:35:53.023 11247-11903/com.example.package E/AndroidRuntime: FATAL EXCEPTION: ModernAsyncTask #1
Process: com.example.package, PID: 11247
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.support.v4.content.ModernAsyncTask$3.done(ModernAsyncTask.java:142)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
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)
Caused by: java.util.ConcurrentModificationException
at java.util.WeakHashMap$HashIterator.next(WeakHashMap.java:165)
at com.google.android.gms.auth.api.signin.internal.zzb.zzafx(Unknown Source)
at com.google.android.gms.auth.api.signin.internal.zzb.loadInBackground(Unknown Source)
at android.support.v4.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:296)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:54)
at android.support.v4.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:42)
at android.support.v4.content.ModernAsyncTask$2.call(ModernAsyncTask.java:128)
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:818)
Thanks in advance.
I'm creating an application that is using NativeAdsManager within a RecyclerView. When I load the ads, I'm getting an out of memory exception. This is where I initialise the NativeAdsManager:
NativeAdsManager manager = new NativeAdsManager(MainActivity.this,PLACEMENT_ID,5);
manager.setListener(MainActivity.this);
manager.loadAds(NativeAd.MediaCacheFlag.ALL);
This is my log when I get the error:
07-07 16:44:37.513 14833-15332/com.example.fbads E/dalvikvm-heap: Out of memory on a 1324560-byte allocation.
07-07 16:44:37.528 14833-15332/com.example.fbads E/k: Error downloading image: https://external.xx.fbcdn.net/safe_image.php?d=AQAUgFkrAP5pYhO4&w=796&h=416&url=http%3A%2F%2Fwww.facebook.com%2Fads%2Fimage%2F%3Fd%3DAQJm1ZveY2ilC4oqvu3Hf63USTwVITC5XBV-qrlWjCWeNgKXrAn5SBB9J6cFyDL0sqpnMWqMDehXuXprwbAKycgE-kskX1q8_jpYlyB4sfhCxSRpHM_5n9ZA8-xhlcZ-VxlRs9DT4i5qeLy6kEZxOSQG&cfs=1&ext=jpg
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:620)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:376)
at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:402)
at com.facebook.ads.internal.util.m.a(Unknown Source)
at com.facebook.ads.internal.util.k.b(Unknown Source)
at com.facebook.ads.internal.util.k.doInBackground(Unknown Source)
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)
Any reasons why this is happening? Any suggestions on how to fix this problem?
I am facing a problem in Samsung Galaxy J5 device
it always gives me an error can't save image when try to take image from camera, also when try to load image from URI I got an exception
Here is example of the URII That I am trying to open
file:///storage/emulated/0/DCIM/Tango/image.jpg
and here is the exception that I got
E/MediaStore: Failed to insert image
java.io.FileNotFoundException: No such file or directory
at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:146)
at android.content.ContentProviderProxy.openAssetFile(ContentProviderNative.java:620)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:943)
at android.content.ContentResolver.openOutputStream(ContentResolver.java:690)
at android.content.ContentResolver.openOutputStream(ContentResolver.java:666)
at android.provider.MediaStore$Images$Media.insertImage(MediaStore.java:961)
at com.forsale.forsale.controller.manager.ForSaleServerManager.getImageUri(ForSaleServerManager.java:3641)
at com.forsale.forsale.controller.manager.ForSaleServerManager.getFileObject(ForSaleServerManager.java:3627)
at com.forsale.forsale.controller.manager.ForSaleServerManager$33.doInBackground(ForSaleServerManager.java:2514)
at com.forsale.forsale.controller.manager.ForSaleServerManager$33.doInBackground(ForSaleServerManager.java:2492)
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)
java.lang.NullPointerException: uriString
at android.net.Uri$StringUri.<init>(Uri.java:471)
at android.net.Uri$StringUri.<init>(Uri.java:461)
at android.net.Uri.parse(Uri.java:433)
at com.forsale.forsale.controller.manager.ForSaleServerManager.getImageUri(ForSaleServerManager.java:3642)
at com.forsale.forsale.controller.manager.ForSaleServerManager.getFileObject(ForSaleServerManager.java:3627)
at com.forsale.forsale.controller.manager.ForSaleServerManager$33.doInBackground(ForSaleServerManager.java:2514)
at com.forsale.forsale.controller.manager.ForSaleServerManager$33.doInBackground(ForSaleServerManager.java:2492)
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)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getName()' on a null object reference
at com.forsale.forsale.controller.manager.MultipartUtility.addFilePart(MultipartUtility.java:54)
at com.forsale.forsale.controller.manager.ForSaleServerManager$33.doInBackground(ForSaleServerManager.java:2515)
at com.forsale.forsale.controller.manager.ForSaleServerManager$33.doInBackground(ForSaleServerManager.java:2492)
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)
You must check your path first. and if it is correct then look for the image naming as 'image.jpg'. this might solve the problem.
I just received this crash report from HockeyApp.
java.lang.RuntimeException: java.io.IOException: failed to rename /data/data/com.company.app/cache/journal to /data/data/com.company.app/cache/journal.bkp
at com.squareup.okhttp.internal.DiskLruCache$1.run(DiskLruCache.java:181)
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)
Caused by: java.io.IOException: failed to rename /data/data/com.company.app/cache/journal to /data/data/com.company.app/cache/journal.bkp
at com.squareup.okhttp.internal.io.FileSystem$1.rename(FileSystem.java:85)
at com.squareup.okhttp.internal.DiskLruCache.rebuildJournal(DiskLruCache.java:408)
at com.squareup.okhttp.internal.DiskLruCache.access$400(DiskLruCache.java:88)
at com.squareup.okhttp.internal.DiskLruCache$1.run(DiskLruCache.java:177)
... 3 more