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?
Related
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 have got error in android version 4
E/ExcelSheet: null
org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:62)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:456)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:162)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:271)
at com.example.vinove.excelsheetapp.Poi.ExcelSheet.readExcelSheet(ExcelSheet.java:63)
at com.example.vinove.excelsheetapp.Activities.MainActivity$MyTask.doInBackground(MainActivity.java:137)
at com.example.vinove.excelsheetapp.Activities.MainActivity$MyTask.doInBackground(MainActivity.java:107)
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.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:60)
at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:456)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:162)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:271)
at com.example.vinove.excelsheetapp.Poi.ExcelSheet.readExcelSheet(ExcelSheet.java:63)
at com.example.vinove.excelsheetapp.Activities.MainActivity$MyTask.doInBackground(MainActivity.java:137)
at com.example.vinove.excelsheetapp.Activities.MainActivity$MyTask.doInBackground(MainActivity.java:107)
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.lang.NoClassDefFoundError: org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory
at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:46)
at java.lang.reflect.Constructor.constructNative(Native Method)
Apache POI will not work out of the box on Android, there are various problems that you will run into.
There are some projects that make it possible to use parts of Apache POI on Android:
https://github.com/andruhon/android5xlsx (for Android 5) and https://github.com/andruhon/AndroidReadXLSX (for Android 4) which is based on Apache POI 3.12
https://github.com/centic9/poi-on-android/ (for Android 5, maintained by me), which can be used with any version of POI, e.g. 3.15 currently
I have upgraded to Google Play Services v9.6, but now i'm getting a exception if i try to use classes such like BitmapDescriptorFactory.
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: nl.rsdt.japp, PID: 3117
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: IBitmapDescriptorFactory is not initialized
at com.google.android.gms.common.internal.zzac.zzb(Unknown Source)
at com.google.android.gms.maps.model.BitmapDescriptorFactory.zzbsg(Unknown Source)
at com.google.android.gms.maps.model.BitmapDescriptorFactory.fromResource(Unknown Source)
at nl.rsdt.japp.jotial.maps.management.controllers.FotoOpdrachtController$FotoOpdrachtTransducer.generate(FotoOpdrachtController.java:164)
at nl.rsdt.japp.jotial.maps.management.controllers.FotoOpdrachtController$FotoOpdrachtTransducer.transduceToBundle(FotoOpdrachtController.java:125)
at nl.rsdt.japp.jotial.maps.management.transformation.async.AsyncBundleTransduceTask.doInBackground(AsyncBundleTransduceTask.java:31)
at nl.rsdt.japp.jotial.maps.management.transformation.async.AsyncBundleTransduceTask.doInBackground(AsyncBundleTransduceTask.java:15)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
In the previous version(v.9.4) calling MapsInitializer.initialize(context); would enable me to use classes such as BitmapDescriptorFactory. But now it doesn't? I have tried MapsInitializer.initialize(context); witch my Application Context and with my Activity Context but both result in the same exception.
The problem has resolved it self for me, you can see the Issue i made on the Issue Tracker here.
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 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.