Finishes the package after the gradle script run :param args: the parser args :param output: RunningCommand output :param build_args: build args as returned by build.parse_args :param package_type: one of 'apk', 'aar', 'aab' :param output_dir: where t
(self, args, output, build_args, package_type, output_dir)
| 1094 | return output, build_args |
| 1095 | |
| 1096 | def _finish_package(self, args, output, build_args, package_type, output_dir): |
| 1097 | """ |
| 1098 | Finishes the package after the gradle script run |
| 1099 | :param args: the parser args |
| 1100 | :param output: RunningCommand output |
| 1101 | :param build_args: build args as returned by build.parse_args |
| 1102 | :param package_type: one of 'apk', 'aar', 'aab' |
| 1103 | :param output_dir: where to put the package file |
| 1104 | """ |
| 1105 | |
| 1106 | package_glob = "*-{}.%s" % package_type |
| 1107 | package_add_version = True |
| 1108 | |
| 1109 | self.hook("after_apk_assemble") |
| 1110 | |
| 1111 | info_main('# Copying android package to current directory') |
| 1112 | |
| 1113 | package_re = re.compile(r'.*Package: (.*\.apk)$') |
| 1114 | package_file = None |
| 1115 | for line in reversed(output.splitlines()): |
| 1116 | m = package_re.match(line) |
| 1117 | if m: |
| 1118 | package_file = m.groups()[0] |
| 1119 | break |
| 1120 | if not package_file: |
| 1121 | info_main('# Android package filename not found in build output. Guessing...') |
| 1122 | if args.build_mode == "release": |
| 1123 | suffixes = ("release", "release-unsigned") |
| 1124 | else: |
| 1125 | suffixes = ("debug", ) |
| 1126 | for suffix in suffixes: |
| 1127 | |
| 1128 | package_files = glob.glob(join(output_dir, package_glob.format(suffix))) |
| 1129 | if package_files: |
| 1130 | if len(package_files) > 1: |
| 1131 | info('More than one built APK found... guessing you ' |
| 1132 | 'just built {}'.format(package_files[-1])) |
| 1133 | package_file = package_files[-1] |
| 1134 | break |
| 1135 | else: |
| 1136 | raise BuildInterruptingException('Couldn\'t find the built APK') |
| 1137 | |
| 1138 | info_main('# Found android package file: {}'.format(package_file)) |
| 1139 | package_extension = f".{package_type}" |
| 1140 | if package_add_version: |
| 1141 | info('# Add version number to android package') |
| 1142 | package_name = basename(package_file)[:-len(package_extension)] |
| 1143 | package_file_dest = "{}-{}{}".format( |
| 1144 | package_name, build_args.version, package_extension) |
| 1145 | info('# Android package renamed to {}'.format(package_file_dest)) |
| 1146 | shprint(sh.cp, package_file, package_file_dest) |
| 1147 | else: |
| 1148 | shprint(sh.cp, package_file, './') |
| 1149 | |
| 1150 | @require_prebuilt_dist |
| 1151 | def apk(self, args): |