Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

[Android][3510] Cannot open files when using expansion file
Started by martin.schreiber9 Jul 22 2019 06:31 AM

10 replies to this topic
64bit expansion files

Best Answer martin.schreiber9 , 06 August 2019 - 01:25 AM

Looks good. Works on my device now. I will check in detail over the next days.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

martin.schreiber9

[GLOBAL: userInfoPane.html]
martin.schreiber9
  • Observer

  • 17 posts
  • Corona SDK

When building my app with version 3502 the app crashes on startup.

 

Error log, tells me that the following failed: dir is nil instead of string.

local dir = system.pathForFile("game/config/color.json", system.ResourceDirectory);
local file, errorString = io.open(dir, "r");

The same code works, if I just set usesExpansionFile to false in build settings.



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,022 posts
  • Corona SDK

This isn't a 64-bit specific issue.

 

This occurs when you are trying to access a file that does not exist in system.ResourceDirectory. If you change to system.DocumentsDirectory, the crash won't occur.

 

e.g. for ResourceDirectory,

local path = system.pathForFile( "ThisFileDoesntExist.json", system.ResourceDirectory )
print( path ) -> nil
local file, errorString = io.open( path, "r" ) -> Runtime error
print( file, errorString )

for DocumentsDirectory,

local path = system.pathForFile( "ThisFileDoesntExist.json", system.DocumentsDirectory )
print( path ) -> outputs path to documents folder
local file, errorString = io.open( path, "r" )
print( file, errorString ) -> nil, no such file or directory

You can add a simple "if path then" check to prevent these crashes.



[TOPIC: post.html]
#3

vlads

[GLOBAL: userInfoPane.html]
vlads
  • Contributor

  • 972 posts
  • Corona Staff

Does same code works on 3480 or something?



[TOPIC: post.html]
#4

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,022 posts
  • Corona SDK

I'm running 3459 and the ResourceDirectory example I posted results in a runtime error: "bad argument #1 to 'open' (string expected, got nil)".

 

I've just been using the following method to prevent the issue.

local path = system.pathForFile( "ThisFileDoesntExist.json", system.ResourceDirectory )
local file, errorString
if path then
	file, errorString = io.open( path, "r" )
end


[TOPIC: post.html]
#5

martin.schreiber9

[GLOBAL: userInfoPane.html]
martin.schreiber9
  • Observer

  • 17 posts
  • Corona SDK

Sorry it took me so long to get back to you. 

 

To clarify, we're using normal apks with expansion files, not android bundles. Our app is larger than 200MB so we're dependant on expansion files. 

We're building all apps (android and iOS) on a Mac, if that makes any difference.

 

 

 

I'm running 3459 and the ResourceDirectory example I posted results in a runtime error: "bad argument #1 to 'open' (string expected, got nil)".

 

I've just been using the following method to prevent the issue.

local path = system.pathForFile( "ThisFileDoesntExist.json", system.ResourceDirectory )
local file, errorString
if path then
	file, errorString = io.open( path, "r" )
end

 

I'm trying to load files, that are packed to the android expansion files (obb files). In this case, color descriptors and localization files. Preventing the crash would not help, as the files are required for the app to function.

This has worked in the past!

 

 

Does same code works on 3480 or something?

 

2019.3476 - works

2019.3480 - works

2019.3486 - Build Error 11

2019.3487 - Build Error 11

2019.3490 - Build Error 11

2019.3502 - does not work

2019.3504 - does not work

2019.3508 - does not work

 

I also retested, if 2019.3508 works, if I set usesExpansionFile to false. Yes, it does. The problem only happens, if an expansion file is created!



[TOPIC: post.html]
#6

martin.schreiber9

[GLOBAL: userInfoPane.html]
martin.schreiber9
  • Observer

  • 17 posts
  • Corona SDK

I tested 2019.3510, it does not work either. 

 

I stripped our problem down to an example project and attached it to this post. I just uploaded the build of that project to a testapp on google: It shows the same crash. Hope that helps fixing the problem.

Attached Files



[TOPIC: post.html]
#7

vlads

[GLOBAL: userInfoPane.html]
vlads
  • Contributor

  • 972 posts
  • Corona Staff

Thanks for the example, it was quite helpful. I think it should be fixed in latest daily build, 3512.

[TOPIC: post.html]
#8

martin.schreiber9

[GLOBAL: userInfoPane.html]
martin.schreiber9
  • Observer

  • 17 posts
  • Corona SDK

  Best Answer

Looks good. Works on my device now. I will check in detail over the next days.



[TOPIC: post.html]
#9

martin.schreiber9

[GLOBAL: userInfoPane.html]
martin.schreiber9
  • Observer

  • 17 posts
  • Corona SDK

There still seems to be problems with this on Android 9. I got send the following Crashlog:

--------- beginning of crash
FATAL EXCEPTION: background thread
Process: com.XXX, PID: 26682
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/client/utils/URLEncodedUtils;
	at com.google.android.vending.licensing.Policy.decodeExtras(Policy.java:183)
	at com.google.android.vending.licensing.APKExpansionPolicy.processServerResponse(APKExpansionPolicy.java:139)
	at com.google.android.vending.licensing.LicenseValidator.handleResponse(LicenseValidator.java:203)
	at com.google.android.vending.licensing.LicenseValidator.verify(LicenseValidator.java:163)
	at com.google.android.vending.licensing.LicenseChecker$ResultListener$2.run(LicenseChecker.java:229)
	at android.os.Handler.handleCallback(Handler.java:907)
	at android.os.Handler.dispatchMessage(Handler.java:105)
	at android.os.Looper.loop(Looper.java:216)
	at android.os.HandlerThread.run(HandlerThread.java:65)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.client.utils.URLEncodedUtils" on path: DexPathList[[zip file "/data/app/com.XXX-8HOybYupzcltEQStmlofaA==/base.apk"],nativeLibraryDirectories=[/data/app/com.XXX-8HOybYupzcltEQStmlofaA==/lib/arm64, /data/app/com.XXX-8HOybYupzcltEQStmlofaA==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]
	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)

Affected Device: Huawei P30 Pro, Android 9.1, Instant crash on App launch



[TOPIC: post.html]
#10

vlads

[GLOBAL: userInfoPane.html]
vlads
  • Contributor

  • 972 posts
  • Corona Staff

Thanks. This is unrelated to the expansion file. Will look at it

[TOPIC: post.html]
#11

vlads

[GLOBAL: userInfoPane.html]
vlads
  • Contributor

  • 972 posts
  • Corona Staff

This should be fixed in latest daily build as well


[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: 64bit, expansion files