我正在RecyclerView
内创建使用NativeAdsManager
的应用程序。当我加载广告时,我发现内存不足异常。这是我初始化NativeAdsManager
:
NativeAdsManager manager = new NativeAdsManager(MainActivity.this,PLACEMENT_ID,5);
manager.setListener(MainActivity.this);
manager.loadAds(NativeAd.MediaCacheFlag.ALL);
当我收到错误时,这是我的日志:
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)
出现这种情况的原因是什么?关于如何解决这个问题的任何建议?