我生成了我的应用APK文件。 现在,当我试图通过我的设备打开它时,我得到:
5474-5474/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.android.packageinstaller, PID: 5474
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
at android.content.res.Resources.loadDrawable(Resources.java:2150)
at android.content.res.Resources.getDrawable(Resources.java:715)
at com.android.packageinstaller.PackageUtil.getAppSnippet(PackageUtil.java:181)
at com.android.packageinstaller.InstallAppProgress.initView(InstallAppProgress.java:248)
at com.android.packageinstaller.InstallAppProgress.onCreate(InstallAppProgress.java:182)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
请帮助我......
我做错了什么?
答案 0 :(得分:0)
Android为图像分配每像素4个字节。除此之外,如果图标在drawable中,android会分配额外的资源来扩展它。
Android在安装应用时可以分配给图标的内存数量也有限制。如果图标太大,应用程序将耗尽内存。
解决方案 - 按照图标设计指南here for adaptive或here for legacy进行操作。如果您不想进入复杂性,只需缩小图标大小,您的应用就可以正常工作。