Skip to content

Commit 15dce3c

Browse files
authored
Merge pull request #2385 from RobertFlatt/enable_androidx
Enable AndroidX
2 parents 7a0a84e + 2df025f commit 15dce3c

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

doc/source/buildoptions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ options (this list may not be exhaustive):
9292
run. See :ref:`arbitrary_scripts_services`.
9393
- ``--add-source``: Add a source directory to the app's Java code.
9494
- ``--no-compile-pyo``: Do not optimise .py files to .pyo.
95+
- ``--enable-androidx``: Enable AndroidX support library.
9596

9697

9798
webview

pythonforandroid/bootstraps/common/build/build.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ def make_package(args):
343343
join(res_dir, 'drawable/icon.png')
344344
)
345345

346+
if args.enable_androidx:
347+
shutil.copy('templates/gradle.properties', 'gradle.properties')
348+
346349
if get_bootstrap_name() != "service_only":
347350
lottie_splashscreen = join(res_dir, 'raw/splashscreen.json')
348351
if args.presplash_lottie:
@@ -706,6 +709,10 @@ def parse_args_and_make_package(args=None):
706709
'topics/manifest/'
707710
'activity-element.html'))
708711

712+
ap.add_argument('--enable-androidx', dest='enable_androidx',
713+
action='store_true',
714+
help=('Enable the AndroidX support library, '
715+
'requires api = 28 or greater'))
709716
ap.add_argument('--android-entrypoint', dest='android_entrypoint',
710717
default=DEFAULT_PYTHON_ACTIVITY_JAVA_CLASS,
711718
help='Defines which java class will be used for startup, usually a subclass of PythonActivity')

pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,13 @@ android {
7676
}
7777

7878
compileOptions {
79+
{% if args.enable_androidx %}
80+
sourceCompatibility JavaVersion.VERSION_1_8
81+
targetCompatibility JavaVersion.VERSION_1_8
82+
{% else %}
7983
sourceCompatibility JavaVersion.VERSION_1_7
8084
targetCompatibility JavaVersion.VERSION_1_7
85+
{% endif %}
8186
{%- for option in args.compile_options %}
8287
{{option}}
8388
{%- endfor %}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
android.useAndroidX=true
2+
android.enableJetifier=true

0 commit comments

Comments
 (0)