打开 Branch 链接时 Android 应用程序崩溃
Posted
技术标签:
【中文标题】打开 Branch 链接时 Android 应用程序崩溃【英文标题】:Android app crashes when opening Branch link 【发布时间】:2017-05-19 14:51:54 【问题描述】:问题如下:
-
从应用抽屉正常打开应用
按主页按钮将应用发送到后台
从 WhatsApp 或 Facebook Messenger 打开 Branch 链接
应用程序崩溃(内存不足)
但是,以下步骤可以正常工作:
-
通过 Branch 链接打开应用
按主页按钮将应用发送到后台
打开不同的分支链接
这是应用崩溃时发生的情况:
05-19 15:56:02.853: E/androidRuntime(19495): Process: com.somecompany.Someapp, PID: 19495
05-19 15:56:02.853: E/AndroidRuntime(19495): java.lang.Error: FATAL EXCEPTION [main]
05-19 15:56:02.853: E/AndroidRuntime(19495): Unity version : 5.6.0f3
05-19 15:56:02.853: E/AndroidRuntime(19495): Device model : Sony D6633
05-19 15:56:02.853: E/AndroidRuntime(19495): Device fingerprint: Sony/D6633/D6633:6.0.1/23.5.A.1.291/2769308465:user/release-keys
05-19 15:56:02.853: E/AndroidRuntime(19495): Caused by: java.lang.OutOfMemoryError: Failed to allocate a 84934668 byte allocation with 16776896 free bytes and 61MB until OOM
05-19 15:56:02.853: E/AndroidRuntime(19495): at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:467)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:497)
05-19 15:56:02.853: E/AndroidRuntime(19495): at com.unity3d.player.i.onLayoutChange(Unknown Source)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.View.layout(View.java:16731)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.ViewGroup.layout(ViewGroup.java:5438)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.View.layout(View.java:16722)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.ViewGroup.layout(ViewGroup.java:5438)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.View.layout(View.java:16722)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.ViewGroup.layout(ViewGroup.java:5438)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
05-19 15:56:02.853: E/AndroidRuntime(19495): at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2685)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.View.layout(View.java:16722)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.ViewGroup.layout(ViewGroup.java:5438)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2175)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1935)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1111)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6017)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.Choreographer.doCallbacks(Choreographer.java:670)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.Choreographer.doFrame(Choreographer.java:606)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.os.Handler.handleCallback(Handler.java:739)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.os.Handler.dispatchMessage(Handler.java:95)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.os.Looper.loop(Looper.java:234)
05-19 15:56:02.853: E/AndroidRuntime(19495): at android.app.ActivityThread.main(ActivityThread.java:5526)
05-19 15:56:02.853: E/AndroidRuntime(19495): at java.lang.reflect.Method.invoke(Native Method)
05-19 15:56:02.853: E/AndroidRuntime(19495): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
05-19 15:56:02.853: E/AndroidRuntime(19495): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
05-19 15:56:02.855: D/ActivityManager(935): New dropbox entry: com.somecompany.Someapp, data_app_crash, 30b67bc9-f4db-4507-b486-a6382778be7f
05-19 15:56:02.857: W/ActivityManager(935): Force finishing activity com.somecompany.Someapp/io.branch.unity.BranchUnityActivity
这是我的清单:
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.somecompany.someapp" android:theme="@android:style/Theme.NoTitleBar" android:versionCode="1" android:versionName="1.0">
<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
<permission android:name="com.somecompany.someapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true" android:name="io.branch.referral.BranchApp">
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="fb1642292226066339" />
<meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ 62138035114" />
<meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ 62138035114" />
<meta-data android:name="com.google.android.gms.version" android:value="8487000" />
<meta-data android:name="wappier_debug" android:value="true" />
<meta-data android:name="io.branch.sdk.TestMode" android:value="false" />
<meta-data android:name="io.branch.sdk.BranchKey.live" android:value="key_live_bnEyrJEa3GdHlq7FeCzr3annDxmJft9j" />
<receiver android:name="com.kii.cloud.unity.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.somecompany.someapp" />
</intent-filter>
</receiver>
<receiver android:name="com.androidnative.features.notifications.LocalNotificationReceiver" />
<receiver android:name="sdk.wappier.com.receivers.WappierReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<service android:name="com.kii.cloud.unity.GcmIntentService" />
<provider android:name="com.facebook.FacebookContentProvider" android:authorities="com.facebook.app.FacebookContentProvider1642292226066339" android:exported="true" />
<activity android:name="com.unity3d.player.UnityPlayerProxyActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait">
<intent-filter>
<action android:name="PACKAGE_NAME.MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait">
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
<activity android:name="io.branch.unity.BranchUnityActivity" android:launchMode="singleTask" android:screenOrientation="sensorLandscape">
<intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="myapp.app.link" />
<data android:scheme="https" android:host="myapp-alternate.app.link" />
</intent-filter>
<data android:host="open" android:scheme="myapp" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="portrait">
<meta-data android:name="android.app.lib_name" android:value="unity" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
</activity>
<activity android:name="com.jirbo.adcolony.AdColonyOverlay" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.jirbo.adcolony.AdColonyFullscreen" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
<activity android:name="com.jirbo.adcolony.AdColonyBrowser" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" />
<activity android:name="com.unity3d.player.VideoPlayer" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|uiMode|touchscreen" />
<activity android:name="com.androidnative.AndroidNativeProxy" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity android:name="com.androidnative.features.social.common.SocialProxyActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="oauth" android:host="com.somecompany.someapp" />
</intent-filter>
</activity>
<activity android:name="com.androidnative.gms.core.GameClientBridge" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation" />
<activity android:name="com.facebook.LoginActivity" android:label="@string/app_name" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation" />
<activity android:name="com.facebook.unity.FBUnityLoginActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.facebook.unity.FBUnityDeepLinkingActivity" android:exported="true" />
<activity android:name="com.facebook.unity.FBUnityDialogsActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity android:name="com.androidnative.gms.core.GooglePlaySupportActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<activity android:name="com.facebook.unity.FBUnityAppLinkActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="" />
</intent-filter>
</activity>
<activity android:name="com.facebook.unity.FBUnityGameRequestActivity" />
<activity android:name="com.facebook.unity.FBUnityCreateGameGroupActivity" />
<activity android:name="com.facebook.unity.FBUnityJoinGameGroupActivity" />
<activity android:name="com.facebook.unity.AppInviteDialogActivity" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.android.vending.CHECK_LICENSE" />
<uses-permission android:name="com.somecompany.someapp.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!--<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />-->
</manifest>
【问题讨论】:
【参考方案1】:位图内存管理可追溯到 Android 早期。我建议使用 Glide 或 Picasso 之类的库来处理您的位图,并根据需要自定义缓存。我不知道你现在在用什么,但这些是我的首选。在 *** 上有大量关于位图 oom 问题的信息,它与 Branch 无关,当然,除非您通过链接引用参数传递大量字节图像数据,在这种情况下我们不支持。如果您继续挣扎并发现它与 Branch 的内存分配相关而不是您的位图,请写信至 integrations@branch.io,我会看看!
【讨论】:
以上是关于打开 Branch 链接时 Android 应用程序崩溃的主要内容,如果未能解决你的问题,请参考以下文章
使用 branch.io 来自 Play 商店的 Android 深层链接
每次启动应用程序时,Branch.io Deeplink 都会打开深层链接
如果应用程序已经打开,则来自 expo-branch 的 Branch.subscribe 不会收到数据