1. 程式人生 > >Android之部分手機(oppo r9s)安裝app出現崩潰問題解決辦法

Android之部分手機(oppo r9s)安裝app出現崩潰問題解決辦法

1、問題現象

部分手機(oppo r9s)安裝release版本的apk出現了崩潰,但是部分手機安裝正常

2、崩潰日誌

01-15 09:42:37.239  5889  5889 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 66064396 byte allocation with 16777216 free bytes and 50MB until OOM
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.graphics.Bitmap.nativeCreate(Native Method)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.graphics.Bitmap.createBitmap(Bitmap.java:843)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.graphics.Bitmap.createBitmap(Bitmap.java:820)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.graphics.Bitmap.createBitmap(Bitmap.java:740)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.graphics.Bitmap.createBitmap(Bitmap.java:665)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at com.oppo.theme.OppoMaskBitmapUtilities.scaleAndMaskBitmap(Native Method)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at com.oppo.theme.OppoConvertIcon.maskBitmap(OppoConvertIcon.java:300)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at com.oppo.theme.OppoConvertIcon.convertIconBitmap(OppoConvertIcon.java:170)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at com.oppo.theme.OppoConvertIcon.convertIconBitmap(OppoConvertIcon.java:104)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.app.OppoThemeHelper.getDrawable(OppoThemeHelper.java:179)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.app.ApplicationPackageManager.loadItemIcon(ApplicationPackageManager.java:2599)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:374)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:165)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at com.android.packageinstaller.utils.PackageUtil.parseApkInfo(PackageUtil.java:395)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at com.android.packageinstaller.InstallAppProgress.initView(InstallAppProgress.java:734)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at com.android.packageinstaller.InstallAppProgress.onCreate(InstallAppProgress.java:475)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:6497)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2507)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.app.ActivityThread.access$1100(ActivityThread.java:165)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:102)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:179)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:5739)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-15 09:42:37.239  5889  5889 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
01-15 09:42:37.257  1508  2578 W ActivityManager:   Force finishing activity com.android.packageinstaller/.InstallAppProgress


3、解決辦法

看到是手機安裝器直接崩潰了

java.lang.OutOfMemoryError
當時就想是不是我程式寫的程式碼導致記憶體溢位了,但是一想不應該,特碼還沒執行就這崩潰了。

我一眼也看不出啥問題,後面請教了同事,一看就看出來了

at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:374)
loadIcon就是載入桌面圖示呀,記憶體溢位肯定是app自己載入的桌面圖標出了問題,mmp,果然是這個原因,後面改了桌面圖示的解析度,當出現了崩潰,我們應該靜下心看下崩潰日誌的提示是啥,就算是系統的,也需要從頭到尾看。