Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bidafiwoc opened this issue Mar 13, 2016 · 2 comments · Fixed by #697
Closed

Comments

@bidafiwoc
Copy link

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!

@brussee
Copy link
Contributor

brussee commented Mar 15, 2016

I encountered the exact same issue when trying pygame when I was blocked by #686.

My workaround was to create a symlink from /opt/android-sdk to /opt/android-sdk-linux and that works.

@inclement
Copy link
Member

Thanks for noticing this and the detailed explanation. It should (hopefully) be fixed by #697, which implements the same method as the SDL2 bootstrap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants