android-js/androidjs

Issue with storage permissions on android 10.

rcoulot opened this issue · 1 comments

Hi,
I built an app with following permissions in package.json
"permission": [
"android.permission.INTERNET",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE"
],
When I deploy it on a samsung galaxy tab S / android v6, it works fine.
When I deploy the same apk on a samsung galaxy tab S6 / android v10, I get following error.
EACCES: permission denied, scandir '/storage/emulated/0/Download'

Note in the back main.js script, I use the following NodeJS API
const fs = require('fs');
fs.readdir(filepath, function (err, files) { ... }

@rcoulot

i think u should modify webview.js file in androidjs-builder

for insert that 'android:requestLegacyExternalStorage':"true",

webview.js file => line : 54

this.manifist = {
            platformBuildVersionCode: "30",
            platformBuildVersionName: "11",
            application: {
                'android:allowBackup': "true",
                'android:appComponentFactory': "android.support.v4.app.CoreComponentFactory",
                'android:debuggable': "false",
                'android:icon': "@mipmap/ic_launcher",
                'android:label': "@string/app_name",
                'android:roundIcon': "@mipmap/ic_launcher_round",
                'android:supportsRtl': "true",
                'android:theme': "@style/AppTheme",
                'android:usesCleartextTraffic': "true",
                'android:requestLegacyExternalStorage':"true",
                'android:hardwareAccelerated': "true"
            },
            activity: {
                'android:configChanges': "keyboard|keyboardHidden|orientation|screenSize",
                'android:name': "com.android.js.webview.MainActivity"
            }
        };

it works to me