Expansion File Problems

Hi,

we uploaded our game to Google Play Console for closed beta testing. When I try to download the game, it downloads ok, but after I start the game, I get a notice (I translated this from Finnish, but I think you’ll get the point) and the game crashes (can’t load a wav-file):

Allow access to use photos, media files for The Sidekicks app

If I answer no, the game starts and I get a new message:

The Sidekicks needs Storage permission! The Sidekicks uses Expansion Files and needs external storage permission to access them, Re-request access?

The problem is that I have the permission allowed:

android = { isGame = true, usesExpansionFile = true, usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.WRITE\_EXTERNAL\_STORAGE", "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", }, googlePlayGamesAppId = "", },

Am I missing something?

Have you add this statement:

usesExpansionFile = true,

in the build.settings files? The detail is here. In the document, and it tells you to add your license key in the config.lua file too.

Thanks orcastelov,

yes the usesExpansionFile attribute is there. I just by mistake copied an old version of the build.settings to the first message (I edited it now). To make sure you believe me :wink: - I managed to upload both apk and the obb files to the Play Console and the app downloaded nicely from the Google Play. When I start the game I get the notice about the permission.

Does it work if you initially grant permission?

If user declines permissions to download expansion file - there is nothing we can do really… If we can’t have storage access to download expansion file, we can’t download & unpack app assets to run the app.

Sorry for the late reply, I missed the notifications.

@Rob - if user grants the permission, all is fine. Well… the app crashes when launched first time.

Maybe I have not described this clearly. I made a short video, where you can see whole procedure: https://www.youtube.com/watch?v=gOS0zSvDtj4&feature=youtu.be

  1. I download the game as a beta tester
  2. The size of the app is 130 Mb
  3. I install it
  4. Launch the game
  5. The game crashes 'cause it can’t load a file from the expansion file
  6. After that the device ask the permission: Allow access to use photos, media files for The Sidekicks app
  7. If I answer yes, I have to quit the app and launch it again.

Do you have the specific error? Can you repeat this while plugged into USB and do an “adb logcat” and capture the console log to see what’s going on?

Rob

Thanks Rob,

The first file: I started the log, clicked download, started the app and got the error

The second file: Cleared and started thee adb log, granted the permission, closed the app and launched the app

I made new tests.

I downloaded Gunman Taco Truck (100+ Mb), so it should use expansion files. I check the permission from the Android settings. There aren’t any. Then I start the app and get the same message: “Allow to Gunman access photos, media and files on your device”. If I answer yes, the game won’t crash (our game crashes). 

I also installed Badlands to make sure that this is not a Corona issue (130 Mb). I get about the same permission message and after allowing the permission, the game starts nicely.

  • So it must be normal that the device asks the permission even though permission are set in build.settings. I didn’t know that.
  • Is there a way to first detect, is the permission allowed? Or how this situation should be handled that at the first launch the game won’t crash? 

When I start our app, the permission message is displayed, but it seems that the app still tries to load assets and crashes:

local bg=display.newImageRect( “pictures/interface/title_bg_halloween.jpg”, 1366, 771) 

adb:
 

11-04 10:27:45.282 26361 27995 I Corona  : WARNING: Failed to find image ‘pictures/interface/title_bg_halloween.jpg’

11-04 10:27:45.282 26361 27995 I Corona  : ERROR: Runtime error

11-04 10:27:45.282 26361 27995 I Corona  : ?:0: attempt to index upvalue ‘?’ (a nil value)

And yes the file is there :wink:

Testing continues…

I installed latest daily build 2017.11.04 and tried with a very basic main.lua and and scene.lua. Still the same problem. The game starts, the permission message is displayed, if the right is granted, the game crashes (Corona  : WARNING: Failed to find image ‘pictures/interface/title_bg_halloween.jpg’). 

main.lua

display.setStatusBar( display.HiddenStatusBar ) local composer = require "composer" composer.gotoScene( "scene1" )

scene1.lua

local composer = require( "composer" ) local scene = composer.newScene() function scene:create( event )     local sceneGroup = self.view local bg=display.newImageRect( "pictures/interface/title\_bg\_halloween.jpg", 1366, 771) end function scene:show( event )     local sceneGroup = self.view     local phase = event.phase     if phase == "will" then     elseif phase == "did" then     end  end function scene:hide( event )     local sceneGroup = self.view     local phase = event.phase     if event.phase == "will" then     elseif phase == "did" then     end  end function scene:destroy( event )     local sceneGroup = self.view end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene

The log is attached. I start the log, before I click “Run the App”.

Please, let me know what else I can try?

Keep your app under 100MB and download assets on demand from your server… it is so much easier!

Thanks Sphere Game Studios,

I would like to use the Expansion Files, because that way the iOS and Android versions would be pretty much identically and the game would run fine when the user is playing offline.

But we have to consider your solution, 'cause now our Android release is on Hold :frowning:

It would be nice to hear from the devs that is this a bug or is something crucial missing in documentation. And is someone working on this at the moment? I’m glad to run some test, if I could know what to test :wink:

Hi @Aatos Media

Could you please send a simple project to support@coronalabs.com. I’m pretty interested in your build.settings. 

Hi Bektur, 

here is the build.settings. If you still need the whole project, I can sent it to you also, though I have to make it simple first :smiley:

settings = { splashScreen =  { enable = false, --image = "ipadproportrait.png" }, orientation = { default = "landscapeLeft",                 supported = { "landscapeLeft", "landscapeRight" }, }, excludeFiles = { -- Include only the necessary icon files on each platform iphone = { "Icon-\*dpi.png", }, android = { "pictures/icons/I\*.png", }, all = { "pictures/background/versio\*", }, },     -- -- iOS Section -- iphone = { xcassets = "Images.xcassets", plist = { ITSAppUsesNonExemptEncryption = false, UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay UILaunchStoryboardName = "LaunchScreen", --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend --[[-- iOS app URL schemes: CFBundleURLTypes = { { CFBundleURLSchemes = { "fbXXXXXXXXX",  -- replace XXXXXXXXX with your Facebook appId } } } --]] } }, -- -- Android Section -- android = { isGame = true, usesExpansionFile = true, usesPermissions = { "android.permission.INTERNET", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.WRITE\_EXTERNAL\_STORAGE", "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", }, googlePlayGamesAppId = "xxxxxxxxxxx", }, plugins =         {             ["plugin.bit"] =             {                 publisherId = "com.coronalabs"             },             ["plugin.unityads"] =             {                 publisherId = "com.coronalabs",                 supportedPlatforms = { iphone=true, android=true }             },             ["plugin.applovin"] =             {                 publisherId = "com.coronalabs",                 supportedPlatforms = { iphone=true, android=true }             },             ["plugin.gpgs"] =             {                 publisherId = "com.coronalabs",                 supportedPlatforms = { android=true }             },             ["CoronaProvider.gameNetwork.apple"] =             {                 publisherId = "com.coronalabs",                 supportedPlatforms = { iphone=true }             },             ["plugin.flurry.analytics"] =             {                 publisherId = "com.coronalabs",                 supportedPlatforms = { iphone=true, android=true }             },             ["plugin.google.iap.v3"] =             {                 publisherId = "com.coronalabs",                 supportedPlatforms = { android=true }             },         } }

Any news/ideas about this?

I was just thinking that could this help us to get around the problem:

https://docs.coronalabs.com/api/library/native/showPopup.html#requestapppermission

I mean if I ask for the (critical) permission in main.lua and only after answering ‘yes’, the title screen is loaded. Maybe I just assumed that this is done automatically.

Sorry I haven’t got a chance to test it yet.

Regarding permission request, it is done automatically actually (at least should be). I will check later.
 

I think I got this.

First I tried to ask the permission manually https://docs.coronalabs.com/api/library/native/showPopup.html#requestapppermission But it didn’t wok. Don’t know why. The permission was granted but maybe 'cause there is also to automatic permission alert, the app crashed, there were multiple alerts and so on.

Then I made a timer that checks every 500ms if the Storage permission is granted. So when the app starts, the permission alert is shown automatically and the game is “paused” and waiting for the answer. It worked, though if I immediately let the app continue to the screen where expansion files are used, some Androids crashed. So after the Storage permission was recognized, I waited 1 sec before continuing and got it working. I’ve tested this with three different Androids and so far so good .

p.s Interesting thing was that when I was trying to make this work, I printed the permissions. The Storage permission wasn’t there:

“android.permission.INTERNET”,

“android.permission.ACCESS_NETWORK_STATE”,

“android.permission.WRITE_EXTERNAL_STORAGE”,

“com.android.vending.BILLING”,

“com.android.vending.CHECK_LICENSE”,

and when looping and printing the permission in the game:

android.permission.INTERNET

android.permission.ACCESS_NETWORK_STATE

com.android.vending.BILLING

com.android.vending.CHECK_LICENSE

I noticed that you have Google Play Games thing activating before the expansion file is done downloading. Try removing all such things from body of main.lua. Just to test, wrap everything in main.lua into timer, like this

[lua]timer.performWithDelay(1000, function()

– …
–all main.lua code is here
– …

end)[/lua]

Tested, but it didn’t work. The method I posted earlier seems to work ok.

The saga continues. With Expansion File, the game has no music!?! Sound effects are working. Also the videos work (m4v). Music is in mp3 format and the sound effects are in wav format. The music works fine with iOS and if install the game to the Android Device. But if I download the same version from the Google Play, no music… This is getting a bit frustrating…