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

kivy / python-for-android / 22259302242

21 Feb 2026 03:24PM UTC coverage: 63.887% (+4.7%) from 59.214%
22259302242

Pull #3198

github

web-flow
Merge 758a52847 into 1fc026943
Pull Request #3198: Bump SDL3 (`3.4.2`) and SDL3_image (`3.4.0`) to the latest stable releases.

1823 of 3111 branches covered (58.6%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 2 files covered. (100.0%)

788 existing lines in 24 files now uncovered.

5287 of 8018 relevant lines covered (65.94%)

5.26 hits per line

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

24.56
/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)
×
UNCOV
23
        return env
×
24

25
    def prebuild_arch(self, arch):
8✔
26
        super().prebuild_arch(arch)
×
UNCOV
27
        ctx_bootstrap = self.ctx.bootstrap.name
×
28

29
        # define macros for Cython, C, Python
30
        tpxi = 'DEF {} = {}\n'
×
31
        th = '#define {} {}\n'
×
UNCOV
32
        tpy = '{} = {}\n'
×
33

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

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

64
        # create config files for Cython, C and Python
UNCOV
65
        with (
×
66
                current_directory(self.get_build_dir(arch.arch))), (
67
                open(join('android', 'config.pxi'), 'w')) as fpxi, (
68
                open(join('android', 'config.h'), 'w')) as fh, (
69
                open(join('android', 'config.py'), 'w')) as fpy:
70

UNCOV
71
            for key, value in config.items():
×
UNCOV
72
                fpxi.write(tpxi.format(key, repr(value)))
×
UNCOV
73
                fpy.write(tpy.format(key, repr(value)))
×
74

UNCOV
75
                fh.write(th.format(
×
76
                    key,
77
                    value if isinstance(value, int) else '"{}"'.format(value)
78
                ))
UNCOV
79
                self.config_env[key] = str(value)
×
80

81
            if bootstrap_name == "sdl2":
×
82
                fh.write('JNIEnv *SDL_AndroidGetJNIEnv(void);\n')
×
83
                fh.write(
×
84
                    '#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n'
85
                )
UNCOV
86
            elif bootstrap_name == "sdl3":
×
87
                fh.write('JNIEnv *SDL_GetAndroidJNIEnv(void);\n')
×
88
                fh.write(
×
89
                    '#define SDL_ANDROID_GetJNIEnv SDL_GetAndroidJNIEnv\n'
90
                )
91
            else:
UNCOV
92
                fh.write('JNIEnv *WebView_AndroidGetJNIEnv(void);\n')
×
UNCOV
93
                fh.write(
×
94
                    '#define SDL_ANDROID_GetJNIEnv WebView_AndroidGetJNIEnv\n'
95
                )
96

97

98
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