diff --git a/pythonforandroid/bootstraps/common/build/build.py b/pythonforandroid/bootstraps/common/build/build.py index fea791db8d..b6de186385 100644 --- a/pythonforandroid/bootstraps/common/build/build.py +++ b/pythonforandroid/bootstraps/common/build/build.py @@ -455,7 +455,8 @@ def make_package(args): "args": args, "service": service, "service_names": service_names, - "android_api": android_api + "android_api": android_api, + "debug": "debug" in args.build_mode, } if get_bootstrap_name() == "sdl2": render_args["url_scheme"] = url_scheme @@ -478,7 +479,8 @@ def make_package(args): aars=aars, jars=jars, android_api=android_api, - build_tools_version=build_tools_version + build_tools_version=build_tools_version, + debug_build="debug" in args.build_mode, ) # ant build templates @@ -543,7 +545,7 @@ def make_package(args): raise e -def parse_args(args=None): +def parse_args_and_make_package(args=None): global BLACKLIST_PATTERNS, WHITELIST_PATTERNS, PYTHON # Get the default minsdk, equal to the NDK API that this dist is built against @@ -661,6 +663,10 @@ def parse_args(args=None): default=join(curdir, 'whitelist.txt'), help=('Use a whitelist file to prevent blacklisting of ' 'file in the final APK')) + ap.add_argument('--release', dest='build_mode', action='store_const', + const='release', default='debug', + help='Build your app as a non-debug release build. ' + '(Disables gdb debugging among other things)') ap.add_argument('--add-jar', dest='add_jar', action='append', help=('Add a Java .jar to the libs, so you can access its ' 'classes with pyjnius. You can specify this ' @@ -807,4 +813,4 @@ def _read_configuration(): if __name__ == "__main__": - parse_args() + parse_args_and_make_package() diff --git a/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle b/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle index fe78dda5a8..63ba86258f 100644 --- a/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle +++ b/pythonforandroid/bootstraps/common/build/templates/build.tmpl.gradle @@ -34,15 +34,22 @@ android { versionName '{{ args.version }}' } - {% if args.sign -%} - signingConfigs { - release { - storeFile file(System.getenv("P4A_RELEASE_KEYSTORE")) - keyAlias System.getenv("P4A_RELEASE_KEYALIAS") - storePassword System.getenv("P4A_RELEASE_KEYSTORE_PASSWD") - keyPassword System.getenv("P4A_RELEASE_KEYALIAS_PASSWD") - } - } + {% if debug_build -%} + packagingOptions { + doNotStrip '**/*.so' + } + {%- endif %} + + {% if args.sign -%} + signingConfigs { + release { + storeFile file(System.getenv("P4A_RELEASE_KEYSTORE")) + keyAlias System.getenv("P4A_RELEASE_KEYALIAS") + storePassword System.getenv("P4A_RELEASE_KEYSTORE_PASSWD") + keyPassword System.getenv("P4A_RELEASE_KEYALIAS_PASSWD") + } + } + {%- endif %} {% if args.packaging_options -%} diff --git a/pythonforandroid/bootstraps/sdl2/__init__.py b/pythonforandroid/bootstraps/sdl2/__init__.py index fec0fd5da9..2b97552dbc 100644 --- a/pythonforandroid/bootstraps/sdl2/__init__.py +++ b/pythonforandroid/bootstraps/sdl2/__init__.py @@ -47,7 +47,8 @@ def run_distribute(self): with open('blacklist.txt', 'a') as fileh: fileh.write('\nsqlite3/*\nlib-dynload/_sqlite3.so\n') - self.strip_libraries(arch) + if not self.ctx.build_as_debuggable: + self.strip_libraries(arch) self.fry_eggs(site_packages_dir) super().run_distribute() diff --git a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml index 86e69371db..a37e720753 100644 --- a/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml +++ b/pythonforandroid/bootstraps/sdl2/build/templates/AndroidManifest.tmpl.xml @@ -55,6 +55,7 @@ An example Java class can be found in README-android.txt -->