Android API 23 XAPK validation failed due to OBB permissions

Hi,

Android 6 devices are getting XAPK validation failed on start up while validating the game OBB as it requires Storage permission to read it. When the device gets restarted the game opens normally without the need of any permissions this is due to the fact that it puts the obb under root user before restart and adjusts the user after restart. There is a bug currently opened on Android for this Google Issue Tracker

I have published my game with Target API 23 and Google Play Console does not allow to lower it so I am stuck with it now but can’t market the game due to this issue. Is there any workaround for this ?

Any help for this ?

I have edited DownloaderActivity.java.template to request for Storage access permission request at first if not granted as temp solution… is there any workarounds else to fix this problem without requesting “dangerous permissions” ?

Thanks.

Hi I’m having the same trouble, but I have never programmed in java.
Would you please tell me what change did you made to fix this issue.
Thanks a lot!

I am also curious what changes you made for this.

I am traveling away right now, I will post this solution changes tomorrow when I get back

THANK YOU SO MUCH! :slight_smile:

Thank you for helping. I look forward to the fix as well

So sorry for the late response, here is what I have done…

I have edited DownloaderActivity.java.template which is mostly located in C:\Program Files\Epic Games\UE_4.16\Engine\Build\Android\Java\JavaTemplates

  • Created a new Java method called doOnCreate()

  • Took all the contents of onCreate method, pasted them into doOnCreate() and called it from onCreate

  • In method doOnCreate() I have added the following code on top to request for Write permission if it was not already granted

     	if (android.support.v4.content.ContextCompat.checkSelfPermission(_download,
                 android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
         != android.content.pm.PackageManager.PERMISSION_GRANTED) {
     			
     			android.support.v4.app.ActivityCompat.requestPermissions(_download,
                 new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE},
                 MY_PERMISSIONS_REQUEST_STORAGE_ACCESS);
     		
     	}
    
  • MY_PERMISSIONS_REQUEST_STORAGE_ACCESS is an integer constant that you need to declare first and assign an integer value to it.

  • Created another override method to check the outcome provided by user for the permission request whether it is granted or not. if granted, calls doOnCreate() method again.

          @Override
     	public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
     		
     		switch (requestCode) {
     			case MY_PERMISSIONS_REQUEST_STORAGE_ACCESS: {
     				// If request is cancelled, the result arrays are empty.
     				if (grantResults.length > 0
     					&& grantResults[0] == android.content.pm.PackageManager.PERMISSION_GRANTED) {
     
     					doOnCreate();
     
     				} else {
     
     					this.finish();
     				}
     				return;
     			}
     		}		
     	}
    
  • That’s it, I hope this helps. This is the basic implementation, you can handle the rejection as you see fit. These information for granting storage access can be referred to in Android documentation for API 23+. Full Java file is also attached (UE V4.16) link text .

Please refer to my answer below.

Oh thanks for this piece of wisdom!!!, Ill give it a try.

I tried this and got “cannot find symbol” error during packaging referring to MY_PERMISSIONS_REQUEST_STORAGE_ACCESS
does anyone know a solution for this?

Do you have an update for version 4.20? I’m having this issue and I try this solution, but I have errors on compiling.

Hey Hossam. I was hoping you could provide additional clarification for me in regards to you your code. I’m implemented it in my project. When I download the app the first time, my splash screen shows, and then the permission dialog shows. I answer “yes” to the permissions. However, since the splash screen is already displayed and I still receive the XAPK File Validation error. Any ideas or further instruction you can provide me with? Would really appreciate it!

Thanks

Can you tell me how to fix this issue for 4.21

Can you please update to downloanderactivity ue 4.21? thanks.

I made a little change to avoid errors on compiling in 4.22. I don’t try this file yet!
link text

Unfortunately this didn’t solve the issue for me. If anyone has another suggestion, please share.