Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android中的Xamarin.Forms应用程序崩溃_Xamarin_Xamarin.android_Xamarin.forms_Out Of Memory - Fatal编程技术网

Android中的Xamarin.Forms应用程序崩溃

Android中的Xamarin.Forms应用程序崩溃,xamarin,xamarin.android,xamarin.forms,out-of-memory,Xamarin,Xamarin.android,Xamarin.forms,Out Of Memory,当用户打开应用程序时,会导致应用程序崩溃的问题是什么 我与HockeyApp集成,错误显示: VMRuntime.newNonMovableArrayjava.lang.OutOfMemoryError:无法分配63701004字节分配,其中包含16777056个可用字节和41MB 直到OOM 回答 我已经用计算机解决了问题 更新Xamarin.Forms Nuget 删除解决方案中的包文件 再次构建解决方案 在您的清单中添加以下行android:hardwareAccelerated=“fal

当用户打开应用程序时,会导致应用程序崩溃的问题是什么

我与HockeyApp集成,错误显示:

VMRuntime.newNonMovableArrayjava.lang.OutOfMemoryError:无法分配63701004字节分配,其中包含16777056个可用字节和41MB 直到OOM

回答 我已经用计算机解决了问题

  • 更新Xamarin.Forms Nuget
  • 删除解决方案中的包文件
  • 再次构建解决方案

  • 在您的清单中添加以下行
    android:hardwareAccelerated=“false”
    android:largeHeap=“true”
    这可能会解决您的问题


    我也有同样的问题。事实证明,多次修改解决了这个问题

    首先,我确保我的应用程序能够处理大量内存。这是您可以在应用程序清单中设置/更改的设置:

    <application
        ...
        android:largeHeap="true"> <!-- This line does the trick. -->
    
    最后,我确保在分配新图像之前,处理分配给图像视图的图像位图(已用内存)。我不确定这是否真的有必要,因为我不相信分配一个新的图像位图没有得到正确的清理,但我把它留在了我的代码中,我仍然对一个平稳运行的应用程序感到满意。例如:

    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
    

    OutOfMemoryError是一个相当自我解释的错误。您可以向我们展示错误发生的相关代码吗?@zett42更新说明您可以尝试在Android Project->Properties->Android Options->Linker中设置堆大小,并将堆大小
    1G
    @ChandreshKhambhayata链接器设置为None?
    <application
        ...
        android:largeHeap="true"> <!-- This line does the trick. -->
    
    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