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<com.unity3d.player.f$1> is not accessible from java.lang.Class<android.app.Fragment>

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

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

 public class YourActivity extends UnityPlayerActivity{

 @Override

protected void onCreate(Bundle context)) {

 super.onCreate(null);  }

在Manifest中 替换原有的UnityPlayerActivityYourActivity

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容