Expansion File - Blank Screen

Hi,

Building and publishing both the app and the expansion file (main…obb) seem to go through smoothly.

However when I start the app it looks like it’s not finding the expansion file. The screen is just white and none of the resources load up.

If I disable expansion and just build the app, I get a single 110K APK file. If I install this on the device, everything works as expected.

I’ve tried completely uninstalling the app but can’t seem to figure out why the expansion file is not installed properly.

During installation, it looks like it’s also downloading the expansion file due to the size.

Anything I can do to debug the problem?

Any help would be appreciated.

Can you post your build.settings file?

After further checking and testing, I’ve found that by default the storage permission is disabled. So I’m currently putting in the code to enable the Storage permissions. The application is crashing first time the permission requests are happening though each subsequent start up works as expected.

My build.settings is included below.

[lua]–
– For more information on build.settings see the Corona SDK Build Guide at:
https://docs.coronalabs.com/guide/distribution/buildSettings

settings =
{
    orientation =
    {
        – Supported values for orientation:
        – portrait, portraitUpsideDown, landscapeLeft, landscapeRight

        default = “landscapeRight”,
        supported = { “landscapeRight”, },
    },
    
    excludeFiles =
    {
        – Include only the necessary icon files on each platform
        iphone = { “Icon-*dpi.png”, },
        android = { “Icon.png”, “Icon-Small-*.png”, “Icon*@2x.png”, },
    },

    –
    – iOS Section
    –
    –
    – Android Section
    –
    android =
    {
        usesExpansionFile = true,
        usesPermissions =
        {
            “android.permission.INTERNET”,
            “android.permission.ACCESS_COARSE_LOCATION”,
            “android.permission.ACCESS_FINE_LOCATION”,
            “android.permission.INTERNET”,
            “com.android.vending.CHECK_LICENSE”,
            “android.permission.WRITE_EXTERNAL_STORAGE”            
        },
    },
    iphone =
    {
        plist =
        {
            NSAppTransportSecurity = { NSAllowsArbitraryLoads=true },
            UIStatusBarHidden = false,
            UIPrerenderedIcon = true, – set to false for “shine” overlay
            --UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

            CFBundleIconFiles =
            {
                “Icon.png”,
                “Icon@2x.png”,
                “Icon-167.png”,
                “Icon-60.png”,
                “Icon-60@2x.png”,
                “Icon-60@3x.png”,
                “Icon-72.png”,
                “Icon-72@2x.png”,
                “Icon-76.png”,
                “Icon-76@2x.png”,
                “Icon-Small.png”,
                “Icon-Small@2x.png”,
                “Icon-Small@3x.png”,
                “Icon-Small-40.png”,
                “Icon-Small-40@2x.png”,
                “Icon-Small-50.png”,
                “Icon-Small-50@2x.png”,
            },
        },
    },
    
    plugins =
    {
        [“plugin.appodeal”] =
        {
            publisherId = “com.coronalabs”
        },
    },
}
 

[/lua]

I put the permission code in main.lua as per below. The prompts for permissions do come up and I confirm each one. Refer to the images at: https://imgur.com/a/Sagck

After exiting the app, when I get back into the app, I still get a blank screen.

[lua]



– main.lua


native.showPopup( “requestAppPermission”, { appPermission={“STORAGE”, “LOCATION”} } )
– hide the status bar
display.setStatusBar( display.HiddenStatusBar )
display.setDefault(“background”, 1, 1, 1)
– require the composer library
local composer = require “composer”

– Add any objects that should appear on all scenes below (e.g. tab bar, hud, etc)

– Add any system wide event handlers, location, key events, system resume/suspend, memory, etc.

– load home
composer.gotoScene( “home” )
 

[/lua]

Just to make sure: have you seen this tutorial https://coronalabs.com/blog/2013/04/17/expansion-file-support-for-android/ ?

Do you have license key in _ config.lua _?

Yes, I’ve been to that tutorial multiple times. In case I missed something.

I also have the license key in the config.lua file.

I’m going to strip all code from the app and just leave a single image to work with and see how I go with that.

I stripped the code down to bare minimum and still getting problems. I’ll include all of the code further below.

After further trial and error I got as far as the following:

  • Uninstall the app and install it fresh from Google Play
  • The app installs, I start it up and I get the first screen which asks for Storage (photos, media…etc) permissions. (screenshot below)
  • Clicking Allow brings up the blank pink screen and does not load up the home lua file.
    NOTE: The home lua file should load a single background image which should fill the screen.

AuZ4aCX.png

r9FZ9th.png

build.settings

[lua]


– For more information on build.settings, see the Project Build Settings guide at:
https://docs.coronalabs.com/guide/distribution/buildSettings

settings =
{
    orientation =
    {
        – Supported values for orientation:
        – portrait, portraitUpsideDown, landscapeLeft, landscapeRight
        default = “landscapeRight”,
        supported = { “landscapeRight”, “landscapeLeft”, },
    },

    –
    – Android section
    –
    android =
    {
        usesExpansionFile = true,
        usesPermissions =
        {
            “android.permission.INTERNET”,
            “com.android.vending.CHECK_LICENSE”,
            “android.permission.WRITE_EXTERNAL_STORAGE”            
        },
    },

    –
    – iOS section
    –
    iphone =
    {
        xcassets = “Images.xcassets”,
        plist =
        {
            UIStatusBarHidden = false,
            UILaunchStoryboardName = “LaunchScreen”,
        },
    },

    –
    – Plugins section
    –
    plugins =
    {

    },

    –
    – Project section
    –
    excludeFiles =
    {
        – Exclude unnecessary files for each platform
        all = { “Icon.png”, “Icon-*dpi.png”, “Images.xcassets”, },
        android = { “LaunchScreen.storyboardc”, },
    },
}
[/lua]

config.lua

[lua]


– For more information on config.lua see the Project Configuration Guide at:
https://docs.coronalabs.com/guide/basics/configSettings

application =
{
    content =
    {
        
        --[[
        imageSuffix =
        {
                ["@2x"] = 2,
                ["@4x"] = 4,
        },
        --]]
    },
    license =
    {
        google =
        {
            key = “MIIBIjANBgkqhkiG9w0BAQEFAA… <I’ve entered my Licence key from the Play Console->Development Tools->Services & API’s page>… 6ahrCQIDAQAB”,
        },
    },
    
}
 

[/lua]

main.lua

[lua]



– main.lua


– hide the status bar
display.setStatusBar( display.HiddenStatusBar )
display.setDefault(“background”, 1, 0, 1)

– require the composer library
local composer = require “composer”

– Add any objects that should appear on all scenes below (e.g. tab bar, hud, etc)

– Add any system wide event handlers, location, key events, system resume/suspend, memory, etc.

– load scene1

composer.gotoScene( “home” )
 

[/lua]

home.lua

[lua]

-------------pan--------------------------------------------------------------------

– scene.lua


local composer = require( “composer” )
local scene = composer.newScene()


function scene:create( event )
    local sceneGroup = self.view
    background = display.newImageRect( “images/background.png”, system.ResourceDirectory, display.contentWidth, display.contentHeight )
    background.x = display.contentCenterX
    background.y = display.contentCenterY
    if (background == nil) then

        local function onComplete( event )
            native.requestExit()
        end
          
        native.showAlert( “Unable to Access”, “Unable to Access files. Try restarting the Clarinet Player again.”, { “Close” }, onComplete)
    else
        native.showAlert( “X for Background”, "Background X is : " … background.x, { “Close” })
    end
    
        
end

function scene:show( event )
    local sceneGroup = self.view
    local phase = event.phase

    if phase == “will” then
        – Called when the scene is still off screen and is about to move on screen
    elseif phase == “did” then
        – Called when the scene is now on screen
        –
        – INSERT code here to make the scene come alive
        – e.g. start timers, begin animation, play audio, etc
        
        – we obtain the object by id from the scene’s object hierarchy
        
    end
end

function scene:hide( event )
    local sceneGroup = self.view
    local phase = event.phase

    if event.phase == “will” then
        – Called when the scene is on screen and is about to move off screen
        –
        – INSERT code here to pause the scene
        – e.g. stop timers, stop animation, unload sounds, etc.)
    elseif phase == “did” then
        – Called when the scene is now off screen
    end
end

function scene:destroy( event )
    local sceneGroup = self.view

    – Called prior to the removal of scene’s “view” (sceneGroup)
    –
    – INSERT code here to cleanup the scene
    – e.g. remove display objects, remove touch listeners, save state, etc
end


– Listener setup
scene:addEventListener( “create”, scene )
scene:addEventListener( “show”, scene )
scene:addEventListener( “hide”, scene )
scene:addEventListener( “destroy”, scene )


return scene
 

[/lua]

Has anybody solved this yet?

I have the same problems, I followed all the guide lines and looked at all the posts on this and there doesn’t seem to be a definitive answer.

I have got it to the point where it asks you for storage permissions and once you answer the question you get a blank screen, then if you kill the app totally and then re-run it it then works, but I can’t ask my client to do that, my app doesn’t have any plugins but it uses the extension file.

Hey guys,

What devices are you testing on? 

@ozgur3 I copied all your files, created project, upload it to Google Play for alpha testing and became the tester.

The app installs, I start it up and I get the second screen with background immediately. No permissions were asked (that’s strange).

Nexus 5, Android 6.0.1

Samsung Galaxy S8 Android 7.0

So I think I know whats happening here, the system will bring up the popup to allow storage and if you click allow although it sets the permissions to yes the app continues running and crashes because there is no permissions setup before the app runs. So to try and fix that I used native.showPopup( “requestAppPermission”, options ) and then you can check the result carry on and it works, in theory!!

I think what is happening is the system’s popup overrides the popup that I am calling and I don’t get any feedback from the popup.

It’s something like that but either way there is a problem here. The system popup pops up before the default loading screen has finished displaying which basically means it’s not the popup i’m initiating it’s the system.

I tested it on a Samsung Galaxy S7 - Android 7.0. I tried multiple times and just could not get it to work. I also tried to Build the app with different versions of Corona SDK. No luck.

After all those tries, I finally gave up. I went with the following workaround:

  • I removed the “usesExpansionFile = true,” setting.
  • Zipped up the large files and uploaded to my own server
  • Wrote code to download and unzip the file to system.DocumentsDirectory
    Including a progress bar
  • Then refer to the files from the system.DocumentDirectory

Not an ideal solution though it works. When Google remove the limitation, I’ll re-build with all of the files. For now it will have to remain like this.

I agree i’ve Tried over a dozen solutions to try and get this to work, somebody needs to look at this immediately as I am now in big trouble with a client because I can’t publish their app, the app is 300mb in size.

anybody?

In this article
https://coronalabs.com/blog/2016/02/16/introducing-new-android-6-features/

It says in the important notes…Apps using expansion files should have STORAGE permissions granted before launching.

How exactly do we achieve that because that is the exact reason it doesn’t work.

For pre-Android 6.0, the permissions are managed by adding entries in build.settings. For Android 6 and later, you have to request permissions. You can look at the “Camera” sample app included with Corona to see how to request permissions on Android.

Rob

With all due respect, the camera permission is not what is needed for expansion files, if I do it the way the camera app does it (and I have tried it several times) you get the same problem, as per your article “Apps using expansion files should have STORAGE permissions granted BEFORE launching.” The key word here is BEFORE, if you don’t launch the app and manually go and set the storage permission on the app before launching then it works, if you request it once the app is launched it can not use the expansion file.

[quote name=“Bektur” post=“371892” timestamp=“1512654168”]Hey guys,   What devices are you testing on?    @ozgur3 I copied all your files, created project, upload it to Google Play for alpha testing and became the tester.   The app installs, I start it up and I get the second screen with background immediately. No permissions were asked (that’s strange).   Nexus 5, Android 6.0.1[/quote] Try not using a “google phone” after a lot of painful looking around it seems this is a problem with Android 6 and 7 but works fine on google devices.

Can you post your build.settings file?

After further checking and testing, I’ve found that by default the storage permission is disabled. So I’m currently putting in the code to enable the Storage permissions. The application is crashing first time the permission requests are happening though each subsequent start up works as expected.

My build.settings is included below.

[lua]–
– For more information on build.settings see the Corona SDK Build Guide at:
https://docs.coronalabs.com/guide/distribution/buildSettings

settings =
{
    orientation =
    {
        – Supported values for orientation:
        – portrait, portraitUpsideDown, landscapeLeft, landscapeRight

        default = “landscapeRight”,
        supported = { “landscapeRight”, },
    },
    
    excludeFiles =
    {
        – Include only the necessary icon files on each platform
        iphone = { “Icon-*dpi.png”, },
        android = { “Icon.png”, “Icon-Small-*.png”, “Icon*@2x.png”, },
    },

    –
    – iOS Section
    –
    –
    – Android Section
    –
    android =
    {
        usesExpansionFile = true,
        usesPermissions =
        {
            “android.permission.INTERNET”,
            “android.permission.ACCESS_COARSE_LOCATION”,
            “android.permission.ACCESS_FINE_LOCATION”,
            “android.permission.INTERNET”,
            “com.android.vending.CHECK_LICENSE”,
            “android.permission.WRITE_EXTERNAL_STORAGE”            
        },
    },
    iphone =
    {
        plist =
        {
            NSAppTransportSecurity = { NSAllowsArbitraryLoads=true },
            UIStatusBarHidden = false,
            UIPrerenderedIcon = true, – set to false for “shine” overlay
            --UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

            CFBundleIconFiles =
            {
                “Icon.png”,
                “Icon@2x.png”,
                “Icon-167.png”,
                “Icon-60.png”,
                “Icon-60@2x.png”,
                “Icon-60@3x.png”,
                “Icon-72.png”,
                “Icon-72@2x.png”,
                “Icon-76.png”,
                “Icon-76@2x.png”,
                “Icon-Small.png”,
                “Icon-Small@2x.png”,
                “Icon-Small@3x.png”,
                “Icon-Small-40.png”,
                “Icon-Small-40@2x.png”,
                “Icon-Small-50.png”,
                “Icon-Small-50@2x.png”,
            },
        },
    },
    
    plugins =
    {
        [“plugin.appodeal”] =
        {
            publisherId = “com.coronalabs”
        },
    },
}
 

[/lua]