在产品发布后 在崩溃记录上经常有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中 替换原有的UnityPlayerActivity
为 YourActivity