• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kivy / python-for-android / 25209533188

01 May 2026 09:24AM UTC coverage: 62.906% (-0.02%) from 62.928%
25209533188

Pull #3312

github

web-flow
Merge 1d8026be3 into f4a40a9b0
Pull Request #3312: Fix android recipe linking with Qt bootstrap

1832 of 3177 branches covered (57.66%)

Branch coverage included in aggregate %.

0 of 2 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

5328 of 8205 relevant lines covered (64.94%)

5.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

22.95
/pythonforandroid/recipes/android/__init__.py
1
from pythonforandroid.recipe import PyProjectRecipe, IncludedFilesBehaviour
8✔
2
from pythonforandroid.util import current_directory
8✔
3
from pythonforandroid import logger
8✔
4

5
from os.path import join
8✔
6

7

8
class AndroidRecipe(IncludedFilesBehaviour, PyProjectRecipe):
8✔
9
    # name = 'android'
10
    version = None
8✔
11
    url = None
8✔
12

13
    src_filename = 'src'
8✔
14

15
    depends = [('sdl3', 'sdl2', 'genericndkbuild'), 'pyjnius']
8✔
16
    hostpython_prerequisites = ["Cython>=0.29,<3.1"]
8✔
17

18
    config_env = {}
8✔
19

20
    def get_recipe_env(self, arch, **kwargs):
8✔
21
        env = super().get_recipe_env(arch, **kwargs)
×
22
        env.update(self.config_env)
×
23

NEW
24
        if self.ctx.bootstrap.name == "qt":
×
NEW
25
            env['ANDROID_MAIN_LIB'] = f'main_{arch.arch}'
×
26

UNCOV
27
        return env
×
28

29
    def prebuild_arch(self, arch):
8✔
30
        super().prebuild_arch(arch)
×
31
        ctx_bootstrap = self.ctx.bootstrap.name
×
32

33
        # define macros for Cython, C, Python
34
        tpxi = 'DEF {} = {}\n'
×
35
        th = '#define {} {}\n'
×
36
        tpy = '{} = {}\n'
×
37

38
        # make sure bootstrap name is in unicode
39
        if isinstance(ctx_bootstrap, bytes):
×
40
            ctx_bootstrap = ctx_bootstrap.decode('utf-8')
×
41
        bootstrap = bootstrap_name = ctx_bootstrap
×
42
        if bootstrap_name in ["sdl2", "sdl3", "webview", "service_only", "service_library", "qt"]:
×
43
            java_ns = u'org.kivy.android'
×
44
            jni_ns = u'org/kivy/android'
×
45
        else:
46
            logger.error((
×
47
                'unsupported bootstrap for android recipe: {}'
48
                ''.format(bootstrap_name)
49
            ))
50
            exit(1)
×
51

52
        config = {
×
53
            'BOOTSTRAP': bootstrap,
54
            'IS_SDL2': int(bootstrap_name == "sdl2"),
55
            'IS_SDL3': int(bootstrap_name == "sdl3"),
56
            'PY2': 0,
57
            'ANDROID_LIBS_DIR': "{}:{}:{}".format(
58
                self.ctx.get_libs_dir(arch.arch),
59
                join(self.ctx.bootstrap.build_dir, 'libs', arch.arch),
60
                join(self.ctx.bootstrap.build_dir, 'obj', 'local', arch.arch)
61
            ),
62
            'JAVA_NAMESPACE': java_ns,
63
            'JNI_NAMESPACE': jni_ns,
64
            'ACTIVITY_CLASS_NAME': self.ctx.activity_class_name,
65
            'ACTIVITY_CLASS_NAMESPACE': self.ctx.activity_class_name.replace('.', '/'),
66
            'SERVICE_CLASS_NAME': self.ctx.service_class_name,
67
        }
68

69
        # create config files for Cython, C and Python
70
        with (
×
71
                current_directory(self.get_build_dir(arch.arch))), (
72
                open(join('android', 'config.pxi'), 'w')) as fpxi, (
73
                open(join('android', 'config.h'), 'w')) as fh, (
74
                open(join('android', 'config.py'), 'w')) as fpy:
75

76
            for key, value in config.items():
×
77
                fpxi.write(tpxi.format(key, repr(value)))
×
78
                fpy.write(tpy.format(key, repr(value)))
×
79

80
                fh.write(th.format(
×
81
                    key,
82
                    value if isinstance(value, int) else '"{}"'.format(value)
83
                ))
84
                self.config_env[key] = str(value)
×
85

86
            if bootstrap_name == "sdl2":
×
87
                fh.write('JNIEnv *SDL_AndroidGetJNIEnv(void);\n')
×
88
                fh.write(
×
89
                    '#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n'
90
                )
91
            elif bootstrap_name == "sdl3":
×
92
                fh.write('JNIEnv *SDL_GetAndroidJNIEnv(void);\n')
×
93
                fh.write(
×
94
                    '#define SDL_ANDROID_GetJNIEnv SDL_GetAndroidJNIEnv\n'
95
                )
96
            else:
97
                fh.write('JNIEnv *WebView_AndroidGetJNIEnv(void);\n')
×
98
                fh.write(
×
99
                    '#define SDL_ANDROID_GetJNIEnv WebView_AndroidGetJNIEnv\n'
100
                )
101

102

103
recipe = AndroidRecipe()
8✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc