Skip to content

Incorrect SDK variable in build.xml with pygame bootstrap and direct p4a invocation #684

@bidafiwoc

Description

@bidafiwoc

This issue is a follow-up to Issue #681 (opened and closed two days ago). Please see that for additional context (ie, install environment, dependency resolution, etc). I'm attempting still to manually create an apk by directly invoking p4a as follows:

p4a apk --sdk_dir /opt/android-sdk-linux
--ndk_dir /opt/android-ndk-r10e
--android_api 15 --ndk_ver r10e-rc4
--private /root/HelloWorld
--package=org.example.helloworld
--name="HelloWorld" --version=0.5
--bootstrap=pygame --requirements=sdl,python2
--dist_name=helloworld

P4a (or, more specifically, python-sh) is now properly resolving "ant"; however, ant is failing due to an error in the build.xml file:

Buildfile: /root/.local/share/python-for-android/dists/helloworld/build.xml

BUILD FAILED
/root/.local/share/python-for-android/dists/helloworld/build.xml:18: Cannot find /opt/android-sdk/tools/ant/build.xml imported from /root/.local/share/python-for-android/dists/helloworld/build.xml

Specifically, my dist's build.xml seems to be trying to import the Android SDK's build.xml from the wrong fully canonicalized file location. Above, note that it looks for it in:

/opt/android-sdk/tools/ant/build.xml

However, the p4a invocation clearly passes the SDK directory parameter as:

/opt/android-sdk-linux

Somehow, p4a is going from "/opt/android-sdk-linux" to "/opt/android-sdk" and thus failing to find the file.

After some digging, I note that this is really due to use of the pygame bootstrap; more specifically, "/root/.local/share/python-for-android/dists/helloworld/build.xml" includes "/root/.local/share/python-for-android/dists/helloworld/local.properties", which itself contains the incorrect SDK directory parameter ("/opt/android-sdk", rather than "/opt/android-sdk-linux").

If we look at "/usr/local/lib/python2.7/dist-packages/pythonforandroid/bootstraps/pygame/init.py", we see this code snippet:

shprint(sh.cp, '-a', join(src_path, 'local.properties'), '.')

So, the pygame bootstrap is simply copying the default "local.properties" (as in the git repo for python-for-android) into my particular dist. I'm assuming that the intention here is that the "local.properties" file is supposed to be a fallback default location for SDK directory, and that my command line parameter ("--sdk_dir /opt/android-sdk-linux" above) at p4a invocation should supersede this default. Clearly, that's not happening.

In fact, though, if I manually change the "local.properties" file to match the correct SDK directory, everything works fine. Also, this bug is NOT triggered with the SDL2 bootstrap (though that triggers yet another bug), and it also is NOT triggered when the toolchain is invoked by buildozer (with "android_new" target). Still, there's a bug somewhere here (even if only a documentation / dependency bug), and I'd like to resolve it, so things work properly with p4a invoked directly.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions