p4a create --dist_name=sdl2 --bootstrap=sdl2 --requirements=sdl2,python2,kivy
gives:
###########
...........
RAN: '/usr/bin/patch -t -d /home/piv/.local/share/python-for-android/build/other_builds/kivy-sdl2/armeabi/kivy -p1 -i /usr/local/lib/python2.7/dist-packages/pythonforandroid/recipes/kivy/android_sdl2_compat.patch'
STDOUT:
patching file kivy/app.py
Reversed (or previously applied) patch detected! Assuming -R.
Hunk #1 succeeded at 326 (offset 3 lines).
Hunk #2 succeeded at 1023 (offset 3 lines).
patching file kivy/core/window/__init__.py
Reversed (or previously applied) patch detected! Assuming -R.
Hunk #1 succeeded at 497 (offset 35 lines).
patching file kivy/core/window/window_sdl2.py
Reversed (or previously applied) patch detected! Assuming -R.
Hunk #1 succeeded at 393 (offset 72 lines).
patching file kivy/metrics.py
Reversed (or previously applied) patch detected! Assuming -R.
Hunk #3 FAILED at 217.
1 out of 3 hunks FAILED -- saving rejects to file kivy/metrics.py.rej
patching file setup.py
Reversed (or previously applied) patch detected! Assuming -R.... (44 more, please see e.stdout)
STDERR:
...........
###########
The problem is that "~/.local/share/python-for-android/build/other_builds/kivy-sdl2/armeabi/kivy/kivy/metrics.py" has already somehow -- at least partly -- patched (e.g. it contains "if USE_SDL2:" statement).
Original "metrics.py" comes/downloaded from "https://codeload.github.com/kivy/kivy/zip/master" during creating distribution then in patching phase fails since wrong differences.
If you edit and regenerate (back-patch) the file based on the relevant patch file:
"/usr/local/lib/python2.7/dist-packages/pythonforandroid/recipes/kivy/android_sdl2_compat.patch"
p4a distribution creation script can finish its job.