From eb12e6c6f698e88f287ae20562dad51e64894475 Mon Sep 17 00:00:00 2001 From: Evstifeev Roman Date: Mon, 15 Jul 2019 11:05:45 +0300 Subject: [PATCH 1/2] Add optional android fileprovider. --- pythonforandroid/bootstraps/common/build/build.py | 5 +++++ .../common/build/src/main/res/xml/.gitkeep | 1 + .../common/build/templates/build.tmpl.gradle | 3 +++ .../sdl2/build/templates/AndroidManifest.tmpl.xml | 12 ++++++++++++ pythonforandroid/toolchain.py | 3 ++- 5 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 pythonforandroid/bootstraps/common/build/src/main/res/xml/.gitkeep diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py index 2b69082f14..6c9341c199 100644 --- a/pythonforandroid/bootstraps/common/build/build.py +++ b/pythonforandroid/bootstraps/common/build/build.py @@ -503,6 +503,9 @@ def make_package(args): remove('AndroidManifest.xml') shutil.copy(manifest_path, 'AndroidManifest.xml') + if args.fileprovider_paths: + shutil.copy(args.fileprovider_paths, join(res_dir, "xml/file_paths.xml")) + # gradle build templates render( 'build.tmpl.gradle', @@ -685,6 +688,8 @@ def parse_args(args=None): ap.add_argument('--depend', dest='depends', action='append', help=('Add a external dependency ' '(eg: com.android.support:appcompat-v7:19.0.1)')) + ap.add_argument('--fileprovider-paths', dest='fileprovider_paths', + help=('Add fileprovider paths xml file')) # The --sdk option has been removed, it is ignored in favour of # --android-api handled by toolchain.py ap.add_argument('--sdk', dest='sdk_version', default=-1, diff --git a/pythonforandroid/bootstraps/common/build/src/main/res/xml/.gitkeep b/pythonforandroid/bootstraps/common/build/src/main/res/xml/.gitkeep new file mode 100644 index 0000000000..8d1c8b69c3 --- /dev/null +++ b/pythonforandroid/bootstraps/common/build/src/main/res/xml/.gitkeep @@ -0,0 +1 @@ + diff --git a/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle b/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle index 32bd091b72..e682e907c4 100644 --- a/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle +++ b/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle @@ -29,6 +29,7 @@ android { targetSdkVersion {{ android_api }} versionCode {{ args.numeric_version }} versionName '{{ args.version }}' + multiDexEnabled true } {% if args.sign -%} @@ -77,4 +78,6 @@ dependencies { compile '{{ depend }}' {%- endfor %} {%- endif %} + compile 'com.android.support:support-v4:26.1.0' + compile 'com.android.support:multidex:1.0.3' } diff --git a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml index 119a4daefd..e5fca5d17c 100644 --- a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml +++ b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml @@ -128,6 +128,18 @@ {% for a in args.add_activity %} {% endfor %} + + {% if args.fileprovider_paths %} + + + + {% endif %} diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index b61c9ac54a..7673e498fe 100644 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -916,7 +916,8 @@ def apk(self, args): # we can't leave it until later as the build.py scripts assume # they are in the current directory. fix_args = ('--dir', '--private', '--add-jar', '--add-source', - '--whitelist', '--blacklist', '--presplash', '--icon') + '--whitelist', '--blacklist', '--presplash', '--icon', + '--fileprovider-paths') unknown_args = args.unknown_args for i, arg in enumerate(unknown_args): argx = arg.split('=') From c3654cef2b39956a252022b263d648c960fd21e2 Mon Sep 17 00:00:00 2001 From: Jamie Alexandre Date: Fri, 17 Apr 2020 23:09:02 -0700 Subject: [PATCH 2/2] Add usesCleartextTraffic flag so webview works for Android 9 & 10. --- .../webview/build/templates/AndroidManifest.tmpl.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml index d71985c66e..7bcd877011 100644 --- a/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml +++ b/pythonforandroid/bootstraps/webview/build/templates/AndroidManifest.tmpl.xml @@ -49,7 +49,8 @@ android:icon="@drawable/icon" android:allowBackup="true" android:theme="{{args.android_apptheme}}{% if not args.window %}.Fullscreen{% endif %}" - android:hardwareAccelerated="true" > + android:hardwareAccelerated="true" + android:usesCleartextTraffic="true" > {% for l in args.android_used_libs %} {% endfor %}