Unity Bug修正: Fragment InstantiationException

在產(chǎn)品發(fā)布后 在崩潰記錄上經(jīng)常有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>

重現(xiàn)步驟:
打開開發(fā)者選項(xiàng)中的 不保留活動(dòng)
重新安裝游戲,等待權(quán)限彈窗出現(xiàn)
權(quán)限彈窗出現(xiàn)后 回到桌面 再?gòu)淖罱顒?dòng)中進(jìn)入游戲

解決方案:
繼承UnityPlayerActivity 重寫onCreate 方法

 public class YourActivity extends UnityPlayerActivity{

 @Override

protected void onCreate(Bundle context)) {

 super.onCreate(null);  }

在Manifest中 替換原有的UnityPlayerActivityYourActivity

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容