Jun 14 Mercurial+ uses API26 (related issue)

In Jun 14 update from Mercurial native readdir() from dirent.h doesn’t work

That’s >2weeks ago, if it didn’t work at all someone should have noticed by now - I think more information is needed:

  • What commit exactly? I only found https://hg.libsdl.org/SDL/rev/7f3c9bffada4 for June 14th and there’s nothing with readdir() in it
  • What operating system are you using?
  • What compiler?
  • What’s the compiler error you’re getting (assuming it’s a compiler error; otherwise: How can the runtime error be reproduced)?


Mercurial SDL update is: SDL-2.0.8-12019.zip from

tested better…
no compile error, just:
DIR* dp = NULL;
dp = opendir(dir); // dp IS NULL!!

so definitively the bug is on opendir()!

I use cygwin to compile Mercurial update + NDK 17b actually.

IMPORTANT: SDL2 2.0.8 May 14 mercurial update 12001 working well!!
The issue is from SDL_REVISION_NUMBER 12002 to 12019

Can you try latest hg code from https://hg.libsdl.org/SDL/archive/bf70bfa02215.zip in case it has been fixed since?

Also, this is weird, because opendir() is implemented by the libc (in your case probably something in cygwin?), not by SDL, so I’m not sure how SDL should break it

tested and https://hg.libsdl.org/SDL/archive/bf70bfa02215.zip it’s the same…

I compile SDL2 from 2.0.1 to 2.0.8 (may 14) and SDK worked well!

I use gygwin and sh androidbuildlibs.sh to compile static lib.
So for some reason native dirent functions are compromised!

Please fix this heavy bug… :cry:

When I compile update: Sam Lantinga slouken@libsdl.org [Tue, 29 May 2018 11:18:01 -0700] rev 12004
I need to use target=android-26 into project.properties (I compile my project with Ant)
If I write:

I have that issue with dirent opendir()

But if I write into manifest just:

All works well!!

So definitely this is not a SDL bug, so… Is from API 26 to UP opendir() broken?? :thinking:

opendir(/mnt/sdcard/…) returns NULL!!

from other tests opendir() works just for first dir level.
example I can see into /mnt but not into /mnt/sdcard
I can see into /storage but not into /storage/emulated…

FOUND ISSUE: from API23 you need to ask READ permissions
In manifest:
< uses-permission android:name=“android.permission.READ_EXTERNAL_STORAGE” / >

then in SDLActivity class if you don’t want to import android.support.v4.app to request permission
just use:

  if (Build.VERSION.SDK_INT >= 23) {
  	String[] permissions = {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};
  	if ( !hasPermissions(permissions) ) {
  		int permsRequestCode = 200; // own custom conventional code for granted permissions
  		requestPermissions(permissions, permsRequestCode);

private boolean hasPermissions(String[] permissions){
Context appCtx = getApplicationContext();
for (String permission : permissions) {
if (appCtx.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) return false;
return true;