Skip to content

Commit

Permalink
fixes release mode misdetection in android_old and android + fix grad…
Browse files Browse the repository at this point in the history
…le detection when copying the apk
  • Loading branch information
tito committed Dec 15, 2017
1 parent fc95dcb commit 83ad94d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
10 changes: 8 additions & 2 deletions buildozer/targets/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ def build_package(self):
mode = 'debug'
else:
build_cmd += [("release", )]
mode = 'release-unsigned'
mode = self.get_release_mode()

self.execute_build_package(build_cmd)

Expand All @@ -787,7 +787,10 @@ def build_package(self):
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:

This comment has been minimized.

Copy link
@AndreMiras

AndreMiras May 21, 2018

Member

@tito we still have issues with this detection method, I can provide a Dockerfile that demonstrates it if it eases debugging.
My setup is Ubuntu Bionic and Python3, buildozer==0.34, build tools 19.1.
The issue seem to be reported or at least closely related to #312, #597, #599, #603, #606, #613, #632, #636, #647, #649, #662.
I think @cdyangbo has it right with his comment #312 (comment)
Should I provide a pull request?

# 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(
Expand Down Expand Up @@ -819,6 +822,9 @@ def build_package(self):
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')
Expand Down
22 changes: 21 additions & 1 deletion buildozer/targets/android_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'''

import sys
import os

from buildozer import USE_COLOR
from buildozer.targets.android import TargetAndroid
Expand Down Expand Up @@ -94,7 +95,8 @@ def execute_build_package(self, build_cmd):
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")
Expand Down Expand Up @@ -153,6 +155,24 @@ def execute_build_package(self, build_cmd):
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')
Expand Down

0 comments on commit 83ad94d

Please sign in to comment.