diff --git a/doc/source/buildoptions.rst b/doc/source/buildoptions.rst index 13a7649027..f56824f953 100644 --- a/doc/source/buildoptions.rst +++ b/doc/source/buildoptions.rst @@ -196,6 +196,7 @@ options (this list may not be exhaustive): - ``add-source``: Add a source directory to the app's Java code. - ``--compile-pyo``: Optimise .py files to .pyo. - ``--resource``: A key=value pair to add in the string.xml resource file. +- ``--enable-androidx``: If the argument is included, the AndroidX support library is enabled. Requirements blacklist (APK size optimization) diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py index 0d51f09135..2789a45fc6 100644 --- a/pythonforandroid/bootstraps/common/build/build.py +++ b/pythonforandroid/bootstraps/common/build/build.py @@ -675,6 +675,11 @@ def parse_args_and_make_package(args=None): 'topics/manifest/' 'activity-element.html')) + ap.add_argument('--enable-androidx', dest='enable_androidx', + action='store_true', + help=('Enable the AndroidX support library, ' + 'add a library using gradle_dependencies, ' + 'requires api = 28 or greater')) ap.add_argument('--android-entrypoint', dest='android_entrypoint', default='org.kivy.android.PythonActivity', help='Defines which java class will be used for startup, usually a subclass of PythonActivity') diff --git a/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle b/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle index f0e2f2068d..178bfe9924 100644 --- a/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle +++ b/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle @@ -96,6 +96,13 @@ android { } } + {% if args.enable_androidx %} + ext { + useAndroidX=true + enableJetifier=true + } + {% endif %} + } dependencies {