2017-03-06 24 views
1

ユーザーがアプリを開いたときにアプリがクラッシュする原因となる問題は何ですか?Xamarin.Forms Androidでクラッシュするアプリ

私はエラーが示され、HockeyAppと統合:

VMRuntime.newNonMovableArray java.lang.OutOfMemoryError: Failed to allocate a 63701004 byte allocation with 16777056 free bytes and 41MB until OOM

Xamarin caused by: java.lang.OutOfMemoryError: Failed to allocate a 63701004 byte 
allocation with 16777056 free bytes and 41MB until OOM 
dalvik.system.VMRuntime.newNonMovableArray(Native Method) 
android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 
android.graphics.BitmapFactory.decodeStreamInternal()BitmapFactory.java:639 
android.graphics.BitmapFactory.decodeStream()BitmapFactory.java:615 
android.graphics.BitmapFactory.decodeStream()BitmapFactory.java:653 

回答 私はすでに

  1. 更新Xamarin.Forms Nugetの問題を解決します。
  2. ソリューション内のパッケージファイルを削除します。
  3. 解決策をもう一度構築します。
+1

OutOfMemoryErrorがかなり自己 – Jason

+0

説明であるあなたが私たちにエラーが発生し、関連するコードを示してもらえますか? – zett42

+0

@ zett42の説明を – tanktaeyang

答えて

2

これらの行をandroid:hardwareAccelerated="false",android:largeHeap="true"に追加すると、問題が解決する場合があります。

<application 
    android:allowBackup="true" 
    android:hardwareAccelerated="false" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:largeHeap="true" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
+0

私はすでに試してみましたが、まだクラッシュしています – tanktaeyang

0

私は同じ問題がありました。複数の変更が問題を解決したことが判明しました。

まず、私のアプリはの大きなメモリヒープを扱うことができます。可能な限り

<application 
    ... 
    android:largeHeap="true"> <!-- This line does the trick. --> 

第二に、私は小さな画像を強制ことを確認しましたのサイズ:これはアプリのマニフェストで/変更設定できる設定です。私の場合は、最大解像度を720ピクセルまたは画面解像度のいずれかに制限することに決めました。その解像度はです。です。私は新しいイメージを割り当て前の画像ビューに割り当てること廃棄画像ビットマップ(使用メモリ)に確保、

int maxImageSideLength = Math.Min(720, Math.Max(myScreenHeight, myScreenWidth)); 
// see tutorials how to resize the image now 

最後:結果として、私は、大きな画像をリサイズ。私は新しい画像ビットマップの割り当てが適切にクリーンアップされていないとは思えないので、これが本当に必要かどうかは不明ですが、私はこれをコードに残しました。例:

Bitmap resizedImage = ResizeImage(fileName, maxImageSideLength); 
imageView.SetImageBitmap(null); // this is to free allocated memory 
imageView.SetImageBitmap(resizedImage); 
GC.Collect(); // dispose of the Java side bitmap 
関連する問題