This Application Has Been Corrupted Error

Hey everyone,

Been trying to find some guidance and hints, but I must have missed something.

Application runs fine on simulator but gives me a ‘this application has been corrupted’ error on Android (Galaxy SII)

Any hints on where and what to dig?

Thanks!!! [import]uid: 91771 topic_id: 15566 reply_id: 315566[/import]

I am getting the same error with Build 591. Is there any way to get some log or debug output on the Android devices? [import]uid: 16734 topic_id: 15566 reply_id: 57671[/import]

Did you find a solution? I have started to get this error as well. Works fine in emulator but gives “This Application has bee corrupted” error in Phone(Nexus) [import]uid: 64174 topic_id: 15566 reply_id: 58650[/import]

a [import]uid: 64174 topic_id: 15566 reply_id: 58649[/import]

This appears to be caused by the inability of the system to find a file. Either one of your file names has a different case in the LUA script than the filename on disc, or (as in my case) it was caused by the WAV files not being in the root folder.

It is a pain that we cannot have a “staging” area built into Corona. What I have to do is run a batch to copy various files where they need to be for the Android platform. I’d rather not have 40 wav files in my root folder (where the LUA files are), at least for development. The iPhone doesn’t require sound files to be in the root, only the Android platform, and only when you have a package made (not while running in the simulator).

Hope that helps. [import]uid: 16734 topic_id: 15566 reply_id: 58654[/import]

Aah! I was using require “mainMenu” but the file was mainmenu.lua.

Thanks Ken! :slight_smile: [import]uid: 64174 topic_id: 15566 reply_id: 58668[/import]

In case anyone else is experiencing this problem but it isn’t due to the case of a filename, it might be due to the following issue I experienced that resulted in the same symptom:

If referencing a file in a subdirectory via system.pathForFile within the main code sequence you will see “This Application has Been Corrupted” when starting the app on an Android device.

e.g. having the following line in your main program will elicit the error.
[lua]local myFilePath = system.pathForFile( “someSubDirectory/someFile”, system.ResourceDirectory)[/lua]

The work around I settled on was to rename and move the file to the top level resource directory and change the line of code to:
[lua]local myFilePath = system.pathForFile( “someSubDirectory_someFile”, system.ResourceDirectory)[/lua]

I had similar code elsewhere i.e. executed as part of a button press and the symptom experienced then was the app simply displayed a blank screen i.e. crashed but didn’t die. [import]uid: 60648 topic_id: 15566 reply_id: 62545[/import]

@james03 I’m currently experiencing this with my web overlay app. It works fine in the simulator and on iOS, but Android devices simply hate it. I’ve had to use others phones but as far as I can tell its not a file naming or location issue as all my files are in root anyway.

Any other ideas?

Thanks,

Matt [import]uid: 8271 topic_id: 15566 reply_id: 63858[/import]

I found the only way to consistently get my Android builds to run is to copy ALL assets down to the root folder. Occasionally a build will run fine with PNG files in sub folders, but for no apparent reason those same builds will stop working and get the “Corrupt” issue after making some code changes.

Since I abhor flat file structures, I just wrote a simple batch to copy over the files from my well laid out project directory into a temp directory for deployment. Since I made this change I haven’t had any problems.

The only thing that Corona documents that needs to be in the root are the wav or other sound files, so we should not have to put our image files in the root too, but this seems to be what fixes it. [import]uid: 16734 topic_id: 15566 reply_id: 63860[/import]

Sorry @horacebury, I haven’t tried to use the web overlay yet (but I intend to so please post solution when you find one).

The only thing I can think of is if you are dynamically generating the HTML, possibly android doesn’t like the documents directory for the web overlay?

If you are not dynamically generating the html, a work around could be to get it from the web? [import]uid: 60648 topic_id: 15566 reply_id: 63902[/import]

I’m getting XML files from the web and storing them in the temporary directory, but I don’t have any image or sound files other than the icons copied from the web overlays sample code. [import]uid: 8271 topic_id: 15566 reply_id: 63953[/import]

Then I would suggest building a bare-bones version that only to does one thing: tries to load a single xml file from the resource directory; and another version that tries to download the same file from the web and load it from the temp directory.

Good luck! [import]uid: 60648 topic_id: 15566 reply_id: 63959[/import]

I have now built 6 versions…

3 are with Corona build 591, 3 are with build 649.
For each Corona build I’ve build:

My own app
The web overlay sample
The web overlay sample, with the following code change:

[lua]-- new function
function copyFile( filename )
local path = system.pathForFile( filename, system.ResourcesDirectory )
local file = io.open( path, “r” )
local aline = file:read("*a")
io.close( file )

path = system.pathForFile( filename, system.TemporaryDirectory )
file = io.open( path, “w” )
file:write( aline )
io.close( file )
end

– calls the new function
copyFile( “localpage.html” )

– changed the baseUrl value from Resources to Temporary
local options = { hasBackground=false, baseUrl=system.TemporaryDirectory, urlRequest=listener }
native.showWebPopup( “localpage.html”, options )[/lua]

Installing all six builds showed that the only work version is the original, unchanged, sample web overlay code.

So, it appears that it is either my ‘copyFile’ function or the use of ‘system.TemporaryDirectory’ with the web overlay which breaks.

It should be noted that it broke in both Corona builds (591 and 649) so this is not a recent thing and not localised to the current stable build, I’m afraid.

That’s my info so far - if anyone can shed light or even throw some ideas for what to test next out, I’d be much obliged.

Matt. [import]uid: 8271 topic_id: 15566 reply_id: 63993[/import]

You’ve got two calls to pathForFile in that code, it’s most likely one of those so I suggest making another couple of even more bare bones versions with just those lines (i.e. one version with one line and one with the other). [import]uid: 60648 topic_id: 15566 reply_id: 64941[/import]

The problem is in line 3 of your sample.

You have:

local path = system.pathForFile( filename, system.ResourcesDirectory )[/code]It should be:local path = system.pathForFile( filename, system.ResourceDirectory )[/code]There should be no "s" before the "Directory". Please refer to the docs:http://developer.anscamobile.com/reference/index/systempathforfile [import]uid: 16734 topic_id: 15566 reply_id: 64946[/import]

The Lua io.open() function cannot access your HTML file from the resource directory because resource files are inside of your APK file. APK files are really zip files and the Lua io APIs do not know how to extract files from within the APK.

That said, you don’t have to extract the HTML file out of the APK’s resource directory at all because all Corona APIs such as native.showWebPopup() can already access your resource files. So, I suggest that you get rid of your copyFile() function and change your code to this…

local options = { hasBackground=false, baseUrl=system.ResourceDirectory , urlRequest=listener }  
native.showWebPopup( "localpage.html", options )   

[import]uid: 32256 topic_id: 15566 reply_id: 64996[/import]

Thanks Joshua. I find it very strange, though, that iOS can copy those files using io.open but Android can’t. I understand that iOS stops writing to the resource directory, but surely the read only content of the Android resource directory is just as readable?

In my app I need to tell the web overlay to read from the temporary directory so I can write files for it there - almost none of my web files are static, so I need the weboverlay to read them as I create them. This works just fine in iOS.

On another track, if it is basically impossible to write your own web pages and have the web overlay access them, well, it’s rather limiting, isn’t it?

Matt [import]uid: 8271 topic_id: 15566 reply_id: 65003[/import]

The Android platform has no problem reading files from your resource directory. What it doesn’t do with the current “release” build is allow you to read files in sub-folders. Sometimes it works, and sometimes it doesn’t. This apparently has been changed/fixed in the daily builds, but has not yet been released for the main build. [import]uid: 16734 topic_id: 15566 reply_id: 65090[/import]

Matt,

Did you try changing the “Resource s Directory” to ResourceDirectory as I explained in an earlier post? You have a typo. That is most likely the root cause of your problem. [import]uid: 16734 topic_id: 15566 reply_id: 65092[/import]

just want to point out that using a program like alogcat can help tremendously when trying to pinpoint errors (on an android device, that is). [import]uid: 49447 topic_id: 15566 reply_id: 65097[/import]