fixes release mode misdetection in android_old and android + fix gradle detection when copying the apk

This commit is contained in:
Mathieu Virbel 2017-12-15 16:44:17 +01:00
parent fc95dcb2af
commit 83ad94d626
2 changed files with 29 additions and 3 deletions

View file

@ -774,7 +774,7 @@ class TargetAndroid(Target):
mode = 'debug'
else:
build_cmd += [("release", )]
mode = 'release-unsigned'
mode = self.get_release_mode()
self.execute_build_package(build_cmd)
@ -787,7 +787,10 @@ class TargetAndroid(Target):
pass
# XXX found how the apk name is really built from the title
if exists(join(dist_dir, "build.gradle")):
gradle_files = ["build.gradle", "gradle", "gradlew"]
is_gradle_build = any((
exists(join(dist_dir, x)) for x in gradle_files))
if is_gradle_build:
# on gradle build, the apk use the package name, and have no version
packagename = config.get('app', 'package.name')
apk = u'{packagename}-{mode}.apk'.format(
@ -819,6 +822,9 @@ class TargetAndroid(Target):
self.buildozer.state['android:latestapk'] = apk_dest
self.buildozer.state['android:latestmode'] = self.build_mode
def get_release_mode(self):
return "release-unsigned"
def _update_libraries_references(self, dist_dir):
# ensure the project.properties exist
project_fn = join(dist_dir, 'project.properties')

View file

@ -4,6 +4,7 @@ Android target, based on python-for-android project
'''
import sys
import os
from buildozer import USE_COLOR
from buildozer.targets.android import TargetAndroid
@ -94,7 +95,8 @@ class TargetAndroidNew(TargetAndroid):
continue
elif option == "release":
cmd.append("--release")
cmd.append("--sign")
if self.check_p4a_sign_env(True):
cmd.append("--sign")
continue
if option == "--window":
cmd.append("--window")
@ -153,6 +155,24 @@ class TargetAndroidNew(TargetAndroid):
cmd = " ".join(cmd)
self._p4a(cmd)
def get_release_mode(self):
if self.check_p4a_sign_env():
return "release"
return "release-unsigned"
def check_p4a_sign_env(self, error=False):
keys = ["KEYALIAS", "KEYSTORE_PASSWD", "KEYSTORE", "KEYALIAS_PASSWD"]
check = True
for key in keys:
key = "P4A_RELEASE_{}".format(key)
if key not in os.environ:
if error:
self.buildozer.error(
("Asking for release but {} is missing"
"--sign will not be passed").format(key))
check = False
return check
def cmd_run(self, *args):
entrypoint = self.buildozer.config.getdefault(
'app', 'android.entrypoint')