Android Expansion Files Error On First Load.

We are trying out the recently added support for android expansion files.

When we install an app to the device it downloads and installs the expansion file fine.

Unfortunately we hit a problem the first time we load the app something goes wrong.

When we restart the app there are no errors and it runs fine.

Also if we install it without using the expansion file (one big apk) we don’t see the error.

Looking at the log we see the following error which leads us to suspect our code is not cleaning up something.

We don’t know why this happens when using expansion files and would like to know if anyone else has seen anything similar?

Using build 2013.1082

I/Corona  ( 5486): Runtime error
I/Corona  ( 5486): ?:0: stack overflow
I/Corona  ( 5486): stack traceback:
I/Corona  ( 5486):      [C]: ?
I/Corona  ( 5486):      ?: in function ‘?’
I/Corona  ( 5486):      ?: in function ‘?’
I/Corona  ( 5486):      ?: in function ‘removeSelf’
I/Corona  ( 5486):      ?: in function ‘remove’
I/Corona  ( 5486):      ?: in function ‘?’
I/Corona  ( 5486):      ?: in function ‘removeSelf’
I/Corona  ( 5486):      ?: in function ‘remove’
I/Corona  ( 5486):      ?: in function ‘?’
I/Corona  ( 5486):      ?: in function ‘removeSelf’
I/Corona  ( 5486):      ?: in function ‘remove’
I/Corona  ( 5486):      …
I/Corona  ( 5486):      ?: in function ‘removeSelf’
I/Corona  ( 5486):      ?: in function ‘remove’
I/Corona  ( 5486):      ?: in function ‘?’
I/Corona  ( 5486):      ?: in function ‘removeSelf’
I/Corona  ( 5486):      ?: in function ‘cleanGroup’
I/Corona  ( 5486):      ?: in function ‘destroy’
I/Corona  ( 5486):      ?: in function ‘?’
I/Corona  ( 5486):      ?: in function ‘_listener’
I/Corona  ( 5486):      ?: in function <?:141>
I/Corona  ( 5486):      ?: in function <?:218>

This is also in the log and might be related.

V/Corona  ( 8214): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
W/System.err( 8214): com.naef.jnlua.LuaRuntimeException: ?:0: attempt to index field ‘_view’ (a nil value)
W/System.err( 8214):    at com.naef.jnlua.LuaState.lua_pcall(Native Method)
W/System.err( 8214):    at com.naef.jnlua.LuaState.call(Unknown Source)
W/System.err( 8214):    at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:74)
W/System.err( 8214):    at CoronaProvider.licensing.google.LuaLoader$1.executeUsing(LuaLoader.java:271)
W/System.err( 8214):    at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:153)
W/System.err( 8214):    at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:274)
W/System.err( 8214):    at com.ansca.corona.Controller.onDrawFrame(Controller.java:233)
W/System.err( 8214):    at com.ansca.corona.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:379)
W/System.err( 8214):    at com.ansca.corona.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)
W/System.err( 8214):    at com.ansca.corona.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)
 

Using the latest build 2013.1088 resolves this issue for us.  (and the above errors don’t appear in the logs anymore.)

This is also in the log and might be related.

V/Corona  ( 8214): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
W/System.err( 8214): com.naef.jnlua.LuaRuntimeException: ?:0: attempt to index field ‘_view’ (a nil value)
W/System.err( 8214):    at com.naef.jnlua.LuaState.lua_pcall(Native Method)
W/System.err( 8214):    at com.naef.jnlua.LuaState.call(Unknown Source)
W/System.err( 8214):    at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:74)
W/System.err( 8214):    at CoronaProvider.licensing.google.LuaLoader$1.executeUsing(LuaLoader.java:271)
W/System.err( 8214):    at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:153)
W/System.err( 8214):    at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:274)
W/System.err( 8214):    at com.ansca.corona.Controller.onDrawFrame(Controller.java:233)
W/System.err( 8214):    at com.ansca.corona.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:379)
W/System.err( 8214):    at com.ansca.corona.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)
W/System.err( 8214):    at com.ansca.corona.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)
 

Using the latest build 2013.1088 resolves this issue for us.  (and the above errors don’t appear in the logs anymore.)

Help!   This is problem is back in build 2013.1094!

As posted above, we find this is in the log along with runtime errors that occur afterwards.

04-27 16:35:07.729: W/System.err(26173): com.naef.jnlua.LuaRuntimeException: ?:0: attempt to index field ‘_view’ (a nil value)
04-27 16:35:07.729: W/System.err(26173):     at com.naef.jnlua.LuaState.lua_pcall(Native Method)
04-27 16:35:07.729: W/System.err(26173):     at com.naef.jnlua.LuaState.call(Unknown Source)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:90)
04-27 16:35:07.729: W/System.err(26173):     at CoronaProvider.licensing.google.LuaLoader$1.executeUsing(LuaLoader.java:276)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:153)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:274)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.Controller.onDrawFrame(Controller.java:233)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:379)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)
 

“CoronaProvider.licensing.google.LuaLoader” leads us to suspect something goes wrong checking the license.

This error only happens the first time the application runs after successfully downloading its expansion file.

The license is valid and correct, the expansion file downloaded without a problem.

If we restart the app there is no error and all is well but we can reproduce the error by clearing the application data (not the expansion file) the error re-appears our app hangs and needs a restart.

With build 2013.1088 we don’t get this error, but another bug prevents the application downloading the expansion file and we have to copy the expansion file over manually to test. See the comments on the below post for that (related?) bug.

http://forums.coronalabs.com/topic/33805-any-documentation-for-expansion-file-support-in-build-20131082/

In case it helps, here is how we are working around the issue to test expansion file downloads and in-app purchases.

We build one apk with build 2013.1094, this build can down load the expansion file.

When the download is complete we install another apk built with build 2013.1088 to test in-app purchases.

The second apk built with the older build does not have errors at startup.

Using build 2013.1095 and we no longer have the runtime error that had something to do with licensing.

We do how ever still have run time errors the first time the app starts. We’ve been digging and feel that it’s probably not related to the expansion file and more todo with the way we cleanup our display objects. We’ll open a new topic for that.

Help!   This is problem is back in build 2013.1094!

As posted above, we find this is in the log along with runtime errors that occur afterwards.

04-27 16:35:07.729: W/System.err(26173): com.naef.jnlua.LuaRuntimeException: ?:0: attempt to index field ‘_view’ (a nil value)
04-27 16:35:07.729: W/System.err(26173):     at com.naef.jnlua.LuaState.lua_pcall(Native Method)
04-27 16:35:07.729: W/System.err(26173):     at com.naef.jnlua.LuaState.call(Unknown Source)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.CoronaLua.dispatchEvent(CoronaLua.java:90)
04-27 16:35:07.729: W/System.err(26173):     at CoronaProvider.licensing.google.LuaLoader$1.executeUsing(LuaLoader.java:276)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:153)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:274)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.Controller.onDrawFrame(Controller.java:233)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:379)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)
04-27 16:35:07.729: W/System.err(26173):     at com.ansca.corona.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)
 

“CoronaProvider.licensing.google.LuaLoader” leads us to suspect something goes wrong checking the license.

This error only happens the first time the application runs after successfully downloading its expansion file.

The license is valid and correct, the expansion file downloaded without a problem.

If we restart the app there is no error and all is well but we can reproduce the error by clearing the application data (not the expansion file) the error re-appears our app hangs and needs a restart.

With build 2013.1088 we don’t get this error, but another bug prevents the application downloading the expansion file and we have to copy the expansion file over manually to test. See the comments on the below post for that (related?) bug.

http://forums.coronalabs.com/topic/33805-any-documentation-for-expansion-file-support-in-build-20131082/

In case it helps, here is how we are working around the issue to test expansion file downloads and in-app purchases.

We build one apk with build 2013.1094, this build can down load the expansion file.

When the download is complete we install another apk built with build 2013.1088 to test in-app purchases.

The second apk built with the older build does not have errors at startup.

Using build 2013.1095 and we no longer have the runtime error that had something to do with licensing.

We do how ever still have run time errors the first time the app starts. We’ve been digging and feel that it’s probably not related to the expansion file and more todo with the way we cleanup our display objects. We’ll open a new topic for that.

Hi Studycat (and Corona foilks);

I hope that you are getting messages on this topic so that you will see this post.

We have the exact same problem that you first posted about on April 17th – but we are experiencing this with two NEWER BUILDS (builds that should no longer have a problem). Any guidance or suggestions you can provide would be great (or from Corona). Here are the details:

  A) When we build an APK (65 Mb) without using an Expansion File and install it on devices via ADB, our app runs fine on first run and forever thereafter.

  B) So, we then build it with an expansion file and place the app in the Google Play store. When we and other users then download/install it from there, the app starts up just fine and gets to a “landing” screen. But as soon as users try to exit that landing screen and go to another screen (via a Director transition), we get an error that is nearly identical to what you posted at the top of this thread. It is:

I/Corona  (19966): Runtime error
I/Corona  (19966): stack traceback:
I/Corona  (19966):      [C]: ?
I/Corona  (19966):      ?: in function ‘remove’
I/Corona  (19966):      ?: in function ‘removeSelf’
I/Corona  (19966):      ?: in function ‘remove’
I/Corona  (19966):      ?: in function ‘clean’
I/Corona  (19966):      ?: in function ‘?’
I/Corona  (19966):      ?: in function ‘_listener’
I/Corona  (19966):      ?: in function <?:141>
I/Corona  (19966):      ?: in function <?:218>
I/Corona  (19966): Runtime error
I/Corona  (19966):
I/Corona  (19966): stack traceback:
I/Corona  (19966):      [C]: ?
I/Corona  (19966):      ?: in function ‘remove’
I/Corona  (19966):      ?: in function ‘removeSelf’
I/Corona  (19966):      ?: in function ‘remove’
I/Corona  (19966):      ?: in function ‘clean’
I/Corona  (19966):      ?: in function ‘?’
I/Corona  (19966):      ?: in function ‘_listener’
I/Corona  (19966):      ?: in function <?:141>
I/Corona  (19966):      ?: in function <?:218>

I noticed you had “cleanGroups” in your error output. But your experience and mine are spookily the same.

C) The game freezes when I get the above error. But if I exit the game entirely and start it back up, the game runs fine on its second play and every time thereafter (with no error message or any other weirdness).  This experience has been duplicated on a number of devices.

So to quickly summarize:

– APKs built with Version 1150 and 1185 perform exactly alike.

– Run the game in the simulator and it produces no error - ever.

– Build a single large APK file and install on devices and it produces no error - ever.

– Build for Google Play with Expansion file and install game from there and the game reproducibly delivers the above error on first launch.

– But that same app (using expansion file) that was installed from Google Play never produces this error on second launch or thereafter.

So any insight which you or Corona folks can provide would be most timely as this is a live App (and a popular one) and I need to fix soonest.

Steve Bullock

Adveractive

Hi,

Are you using widgets in your app?

Hi sbullock

If I recall correctly I think we eventually found that in some cases overriding corona sdk functions had something to do with it.

We were overriding the display.newGroup function and the remove and removeSelf functions.

This is the code that was breaking our project:

[lua]

local oldNewGroup = display.newGroup

display.newGroup = function( … )

    local group = oldNewGroup( … )

    local oldRemoveSelf = group.removeSelf

    

    group.removeSelf = function( self )

        if self.numChildren then

            for i = self.numChildren, 1, -1 do

                self[i]:removeSelf()

             end

         end

        

        oldRemoveSelf( self )

    end

    group.remove = function( self, o )

        if type( o ) == ‘number’ then

            self[o]:removeSelf()

        else

            print “group.remove removeSelf”

            o:removeSelf()

        end

    end

    return group

end

[/lua]

We had a source file “cleangroup.lua” which I strongly suspect was pulled off the internet somewhere to deal with clean up issues that are a non-issue now. Once we stopped overriding display.newGroup it worked for us.

Later we had a response on bug report, Corona told us they though it could be because widget’s and our code were both overriding the display.newGroup function.  That explanation fitted very well.

I hope this helps.  

Hi Studycat and dchan;

Thanks for your thoughts. We are not using widgets.

And to our knowledge, none of our code or functions are overriding any standard Corona functions.

We use a “clean” function in our screen scripts. This “clean” function is called by director.lua from director’s “callClean” function – when transitioning from screen to screen. Studycat’s post has me wondering if SOMETHING is triggering an extra call to one of these functions.

What I don’t understand is why this is entirely a “first run when there is an expansion file present” problem. I realize that there is some Corona code running this first time to link the two files together properly – but why should that code be impacting a specific code execution of mine that runs reliably in all other instances (note – same App with same code has been released on iOS and on Nook/Android).

Dchan – can you advise if the Corona code for handling of expansion files might have any functions named “clean”, “callClean” or “cleanGroups” that isn’t being cleaned up after it runs . . . or anything similar? Or if you have any other thoughts, it would be very welcome.

A big part of my problem is that I haven’t quite figured out is how to do the “expansion file” thing using adb on a local device. So I am essentially stuck with posting builds to a live app (fyi, the Google Play “beta” feature they added doesn’t let you test a beta install properly if the App i already live – it is really poorly done).

Thanks for any more thoughts you might offer.

Steve

Can you add a require(“widget”) to the top of your code and then run it in the simulator and see if the problem occurs?  I believe the issue isn’t really with expansion files but widgets.  The widget library overrides certain functions such as display.newGroup(). If you try to override those functions and do a recursive call it will cause unexpected behavior.  

This happens the first time with expansion files is because the first time the application is run, we need to check Google’s licensing server to make sure we have the correct expansion file.  When we do that we’re requiring the widget library in case we need to display the downloading screen.

Hi dchan;

That’s exactly the problem. So happy that you have identified it.

So, in essence, the Widget library destroys the normal functionality of a group (created with display.newGroup()). That’s interesting.

Do you have any sample code that can restore the “normal” functionality and remove the widget-induced error? I’m sure hoping so :-).

Thanks for being so prompt in getting me your advice.

Steve

Hi,

One possible option is to include the widget library inside your own project and then remove the override of display.newGroup().  You can find the library here: https://github.com/coronalabs/framework-widgets.  Thats the only work around we have right now but we’ll see if we can find something better.

Hi dchan;

Thanks. A couple of questions:

– I am a Pro Subscriber (not Enterprise). Is the Widget Library something that I can include by simply placing “it” (a .lua file, a directory, etc.) in my main folder?

– When I do a build requiring the expansion file, your build software will know to not overwrite “my widget” with the “normal widget” library. Correct?

– And the url you are providing above for the widget library returns a 404 error :-).

Thanks;

Steve

  1. Yes that would be how you do it

  2. Yes thats how it should be

  3. https://github.com/coronalabs/framework-widgets