Open Sortexsvg opened 4 years ago
Thanks for posting this issue.
Is this something you can reproduce locally? Does it occur consistently or only occasionally?
There is a known issue in the underlying Play Core library that would produce the error you mention. It occurs when the app's Application.OnCreate() process takes a long time (on the order of 5-10 seconds). You could try reducing the amount of data you load in your initial scene and see if that fixes the issue. You could also add a Thread.sleep() into the UnityPlayerActivity OnCreate method to reproduce it locally.
You can try updating the Plugin Version to 1.2 which includes the latest version of Play Core which includes fixes for other bugs that could lead to the Context.startForegroundService() error.
Let me know if any of these options work for you.
Thanks for your response.
Here is the answer for your questions.
Is this something you can reproduce locally?
Does it occur consistently or only occasionally?
I can edit UnityPlayerActivity only in Android Studio. To do that I have to exporty project. But gradle project do not include on demand asset bundles right?
Then How can I edit UnityPlayerActivity ?
You're right that exported gradle projects don't include on demand asset bundles. I know of two ways to add code to the UnityPlayerActivity.onCreate() method :
/Applications/Unity/Hub/Editor/2018.4.6f1/PlaybackEngines/AndroidPlayer/Source/com/unity3d/player/UnityPlayerActivity.java
I have updated the Plugin and still issue didn't solve. ANR exceptions keep coming. Is there any other fix I should try?
Thank you for trying the latest update. If the updating the plugin didn't fix the issue, it is either being caused by the issue I mentioned in my first comment, or is something unrelated and unknown.
Have you tried reproducing the issue by editing the UnityPlayerActivity?
Sorry for the late reply.
We could not able to reproduce the issue by editing the UnityPlayerActivity.
Any other method you can suggest us?
We also encountered the same issue. A few users had this ANR. We suggested them upgrading the Google Play App. Some of them can solve it. We don’t know how to fix it by coding, any suggestions? Thank you.
I add startForeground() in AssetPackExtractionService.java; I find ExtractionForegroundService.java have startForeground(),but AssetPackExtractionService is not have this;
I add startForeground() in AssetPackExtractionService.java; I find ExtractionForegroundService.java have startForeground(),but AssetPackExtractionService is not have this;
Can you describe how did you do that for Unity? Did that help with ANRs in Google Console?
Hi ,i also have this problem in my app ,have you solved ?
I am getting the ANR exception in PlayStore Console .
Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{20915a2 u0 com.packages.name/com.google.android.play.core.assetpacks.AssetPackExtractionService}.
How to slove this?
Few user also complained that asset bundle didn't download. It was stuck at some point. Didn't progress further. If I get any error during the asset bundle download, I will start downloading once again until the download is successful.
I will put 5 to 6 asset bundle at a time for download. Below I have written the code to download 5 to 6 asset bundle.
//--------------------------------------------------------------------------------- for(int i=0;i<assetbundleNames.Count;i++) { StartCoroutine( DownloadAssetBundle(assetbundleNames[i])); }
IEnumerator DownloadAssetBundle(string assetBundleName) { PlayAssetBundleRequest bundleRequest = PlayAssetDelivery.RetrieveAssetBundleAsync (assetBundleName); while (!bundleRequest.IsDone) { yield return null; } if (bundleRequest.Error != AssetDeliveryErrorCode.NoError) { // Will start Download Once again DownloadAssetBundleOnceAgain(assetBundleName); } else { // No error . So Will Cache Asset Bundle AssetBundle assetBundle = bundleRequest.AssetBundle; } } //---------------------------------------------------------------------------------
How can I solve this?
I am using - Unity 2018.4.20 - Play Asset Plugin Version 1.1 Same facing problem any one resolve its?
I got this problem too
We also encountered the same issue I am using - Unity 2018.4.36
This Unity plugin behaves well. The underlying issue is in the com.google.android.play.core
package.
There is a known issue in the underlying Play Core library that would produce the error you mention. It occurs when the app's Application.OnCreate() process takes a long time (on the order of 5-10 seconds). You could try reducing the amount of data you load in your initial scene and see if that fixes the issue. You could also add a Thread.sleep() into the UnityPlayerActivity OnCreate method to reproduce it locally.
@jamcohen is there a link to this issue in the Google issue tracker?
It would be helpful to have a link that I can reference.
I add startForeground() in AssetPackExtractionService.java; I find ExtractionForegroundService.java have startForeground(),but AssetPackExtractionService is not have this;
This method works well, after test. Modify the method, check my ZhiHu: https://zhuanlan.zhihu.com/p/577738203?
I am getting the ANR exception in PlayStore Console .
Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{20915a2 u0 com.packages.name/com.google.android.play.core.assetpacks.AssetPackExtractionService}.
How to slove this?
Few user also complained that asset bundle didn't download. It was stuck at some point. Didn't progress further. If I get any error during the asset bundle download, I will start downloading once again until the download is successful.
I will put 5 to 6 asset bundle at a time for download. Below I have written the code to download 5 to 6 asset bundle.
//--------------------------------------------------------------------------------- for(int i=0;i<assetbundleNames.Count;i++) { StartCoroutine( DownloadAssetBundle(assetbundleNames[i])); }
IEnumerator DownloadAssetBundle(string assetBundleName) { PlayAssetBundleRequest bundleRequest = PlayAssetDelivery.RetrieveAssetBundleAsync (assetBundleName); while (!bundleRequest.IsDone) { yield return null; } if (bundleRequest.Error != AssetDeliveryErrorCode.NoError) { // Will start Download Once again DownloadAssetBundleOnceAgain(assetBundleName); } else { // No error . So Will Cache Asset Bundle AssetBundle assetBundle = bundleRequest.AssetBundle; } } //---------------------------------------------------------------------------------
How can I solve this?
I am using