kivy / kivy/python-for-android

String argument from Buildozer not decoded.

Đang mở
#2,905 5 bình luận 2 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
8.9k
Fork
2k
Merge trung bình
12 giờ 20 phút
Pull request đã merge (30 ngày)
9

Mô tả

### Checklist

- [ x] the issue is indeed a bug and not a support request
- [ x] issue doesn't already exist: https://github.com/kivy/python-for-android/issues
- [x ] I have a short, runnable example that reproduces the issue
- [ x] I reproduced the problem with the latest development version (`p4a.branch = develop`)
- [ x] I used the grave accent (aka backticks) to format code or logs when appropriated

### Versions

- Python: 3.11
- OS: WSL/Ubuntu
- Kivy: 2.2.1
- Cython: 0.29.33
- OpenJDK: 17

### Description

In buildozer.spec , setting:
```
android.extra_manifest_application_arguments = somefile.xml
```
Where `somefile.xml` contains:
```
android:usesCleartextTraffic="true"
```
results in an excaped string argument from Buildozer to p4a:
```
# Run ['/usr/bin/python3', '-m', 'pythonforandroid.toolchain', 'apk', '--bootstrap', 'sdl2', '--dist_name', 'oauth_gspread_example', '--name', 'OG', '--version', '0.1', '--package', 'org.reallyatest.oauth_gspread_example', '--minsdk', '21', '--ndk-api', '21', '--private', '/home/bobf/ex/oauth_gspread_example/.buildozer/android/app', '--permission', 'INTERNET', '--android-entrypoint', 'org.kivy.android.PythonActivity', '--android-apptheme', '@android:style/Theme.NoTitleBar', '--orientation', 'portrait', '--window', '--enable-androidx', '--copy-libs', '--add-source', '/home/bobf/ex/oauth_gspread_example/java', '--extra-manifest-application-arguments="android:usesCleartextTraffic=\\"true\\" "', '--arch', 'arm64-v8a', '--color=always', '--storage-dir=/home/bobf/ex/oauth_gspread_example/.buildozer/android/platform/build-arm64-v8a', '--ndk-api=21', '--ignore-setup-py', '--debug']
```
the key part to note is the value from `somefile.xml` has been quoted and escaped:
```
'--extra-manifest-application-arguments="android:usesCleartextTraffic=\\"true\\" "'
```
The value is written without interpretation to `AndroidManifest.xml` as an escaped string
```
" or "/>".
```
The last but one line in the `AndroidManifest.xml` snippet above should the same a the contents of `somefile.xml`
```
android:usesCleartextTraffic="true"
```

Presumably, Buildozer has to quote and escape in order to pass the argument, so the issue is assumed to be a failure of the p4a parser to decode the argument.

Since we presumably know Buildozer's (quote and escape) encoding algorithm, it should be possible to successfully decode. A simpler approach might be a new p4a argument receiving the file name, and Buildozer supplying the file name.

I didn't test but this may also apply to the `buildozer.spec` `android.extra_manifest_xml` option.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách theo dõi cách p4a xử lý --extra-manifest-application-arguments, từ lệnh được hiển thị trong issue cho đến khi tạo AndroidManifest.xml; so sánh với các đầu vào từ buildozer.spec và somefile.xml. Tái hiện ví dụ trên Python 3.11 trong WSL/Ubuntu, sau đó xác minh rằng manifest được tạo có android:usesCleartextTraffic="true" dưới dạng một thuộc tính và Gradle chấp nhận thuộc tính đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, python
Lĩnh vực
build-system, mobile
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.