Unity Bug修正: Fragment InstantiationException

在产品发布后 在崩溃记录上经常有0.3%的崩溃记录
unity版本 5.6.2
Unable to start activity ComponentInfo{xxx/com.unity3d.player.UnityPlayerActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.unity3d.player.f$1: make sure class name exists, is public, and has an empty constructor that is public
caused by android.app.Fragment$InstantiationException
Unable to instantiate fragment com.unity3d.player.f$1: make sure class name exists, is public, and has an empty constructor that is public`

Caused by java.lang.IllegalAccessException java.lang.Class is not accessible from java.lang.Class

重现步骤:
打开开发者选项中的 不保留活动
重新安装游戏,等待权限弹窗出现
权限弹窗出现后 回到桌面 再从最近活动中进入游戏

解决方案:
继承UnityPlayerActivity 重写onCreate 方法

 public class YourActivity extends UnityPlayerActivity{

 @Override

protected void onCreate(Bundle context)) {

 super.onCreate(null);  }

在Manifest中 替换原有的UnityPlayerActivityYourActivity

你可能感兴趣的:(Unity Bug修正: Fragment InstantiationException)