Repository navigation
Closed
Labels
Description
Checklist
- the issue is indeed a bug and not a support request
- issue doesn't already exist: https://github.com/kivy/python-for-android/issues
- I have a short, runnable example that reproduces the issue
- I reproduced the problem with the latest development version (
p4a.branch = develop) - I used the grave accent (aka backticks) to format code or logs when appropriated
Versions
- Python: 3.8.2
- OS: Docker
- Kivy: N/A
- Cython: 0.29.19
- OpenJDK: 1.8.0_252
Description
I am trying to package a flask app. Hello World App.
Command:
$ docker run \
--interactive \
--tty \
--volume "$PWD":/home/user/app/testapps \
my_p4a_dist bash
$ source venv/bin/activate
$ cd testapps/
$ p4a apk --private . --package=org.example.myapp --name "My WebView Application" --version 0.1 --bootstrap=webview --requirements=flask,feedparser --port=5000 --sdk-dir $ANDROID_HOME/android-sdk --ndk-dir $ANDROID_HOME/android-ndk --debugSpec file: N/A
Logs
Log stating some symbols "DialogInterface", "AlertDialog" and "KeyEvent" were not found.
Listing '/home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/webview_includes'...
[INFO]: Detected highest available build tools version to be 28.0.2
[DEBUG]: -> running gradlew assembleDebug
[DEBUG]: Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details
[DEBUG]:
[DEBUG]: > Task :compileDebugJavaWithJavac FAILED
[DEBUG]: /home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:245: error: cannot find symbol
[DEBUG]: public boolean onKeyDown(int keyCode, KeyEvent event) {
[DEBUG]: ^
[DEBUG]: symbol: class KeyEvent
[DEBUG]: location: class PythonActivity
[DEBUG]: /home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:130: error: package AlertDialog does not exist
[DEBUG]: AlertDialog.Builder dlgAlert = new AlertDialog.Builder(PythonActivity.mActivity);
[DEBUG]: ^
[DEBUG]: /home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:130: error: package AlertDialog does not exist
[DEBUG]: AlertDialog.Builder dlgAlert = new AlertDialog.Builder(PythonActivity.mActivity);
[DEBUG]: ^
[DEBUG]: /home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:137: error: package DialogInterface does not exist
[DEBUG]: new DialogInterface.OnClickListener() {
[DEBUG]: ^
[DEBUG]: /home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:247: error: cannot find symbol
[DEBUG]: if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
[DEBUG]: ^
[DEBUG]: symbol: variable KeyEvent
[DEBUG]: location: class PythonActivity
[DEBUG]: Note: Some input files use or override a deprecated API.
[DEBUG]: Note: Recompile with -Xlint:deprecation for details.
[DEBUG]: 5 errors
[DEBUG]:
[DEBUG]:
[DEBUG]: FAILURE: Build failed with an exception.
[DEBUG]:
[DEBUG]: * What went wrong:
[DEBUG]: Execution failed for task ':compileDebugJavaWithJavac'.
[DEBUG]: > Compilation failed; see the compiler error output for details.
[DEBUG]:
[DEBUG]: * Try:
[DEBUG]: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[DEBUG]:
[DEBUG]: * Get more help at https://help.gradle.org
[DEBUG]:
[DEBUG]: BUILD FAILED in 29s
[DEBUG]: 15 actionable tasks: 3 executed, 12 up-to-date
[DEBUG]:
[DEBUG]:
Exception in thread background thread for pid 163:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/user/app/venv/lib/python3.8/site-packages/sh.py", line 1662, in wrap
fn(*args, **kwargs)
File "/home/user/app/venv/lib/python3.8/site-packages/sh.py", line 2606, in background_thread
handle_exit_code(exit_code)
File "/home/user/app/venv/lib/python3.8/site-packages/sh.py", line 2304, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/user/app/venv/lib/python3.8/site-packages/sh.py", line 877, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/gradlew assembleDebug
STDOUT:
Starting a Gradle Daemon, 2 incompatible and 1 stopped Daemons could not be reused, use --status for details
> Task :compileDebugJavaWithJavac FAILED
/home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:245: error: cannot find symbol
public boolean onKeyDown(int keyCode, KeyEvent event) {
^
symbol: class KeyEvent
location: class PythonActivity
/home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:130: error: package AlertDialog does not exist
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(PythonActivity.mActivity);
^
/home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:130: error: package AlertDialog does not exist
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(PythonActivity.mActivity);
^
/home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:137: error: package DialogInterface does not exist
new DialogInterface.OnClickListener() {
^
/home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java:247: error: cannot find symbol
if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
^
symbol: variable KeyEvent
location: class PythonActivity
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
5 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 29s
15 actionable tasks: 3 executed, 12 up-to-date
[INFO]: STDOUT (last 20 lines of 47):
[DEBUG]:Note: Recompile with -Xlint:deprecation for details.
5 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 29s
15 actionable tasks: 3 executed, 12 up-to-date
[INFO]: STDERR:
[INFO]: COMMAND:
cd /home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a && /home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/gradlew assembleDebug
[WARNING]: ERROR: /home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/gradlew failed!
Solution (or workaround)
import android.content.DialogInterface;
import android.app.AlertDialog;
import android.view.KeyEvent;needed to be added to
/home/user/.local/share/python-for-android/dists/unnamed_dist_1__armeabi-v7a/src/main/java/org/kivy/android/PythonActivity.java
below line
package org.kivy.android;Reacted by Andre Miras, Mathias Lindström, yingshaoxo, harish1996 and David Saldubehere
Activity
AndreMiras commentedon Jun 3, 2020
That's the type of bug reports I'd like to see more often 💪 Kudos for the effort to respect the format and the investigation regarding the solution 👏
So you're saying I introduced a regression in https://github.com/kivy/python-for-android/pull/2187/files#diff-6d13f4ee93e76e3cd43f2bb12409e0b3L20-L22 😅
I think your solution is valid, please make a pull request with it, otherwise I can make it myself later
AndreMiras commentedon Jun 3, 2020
@sak96 give it a try with
p4a.branch = developand close the issue if that fixes it for you.sak96 commentedon Jun 3, 2020
Will do tommorrow (late night here).
Does docker build pickup the changes as the command in dockerfile has not changed. Is there any way to start the build from a given step (incremental) ? I have to check this out. I have some data bandwidth issue at my location so not sure if I will be able to download the whole thing. Will close the bug once things work or you may close it if you want.
Thanks for quick responses. It was really helpful.
AndreMiras commentedon Jun 3, 2020
It depends what you mean with Docker we do have images that get updated automatically on merge to develop and master for both buildozer and python-for-android.
The python-for-android Dockerfile should indeed benefit from incremental update if you pull it as only the last layer should be affected.
Anyway, even with a limited connection
buildozer android cleanwould not delete the dist so it won't need to re-download everything. Mainly the only thing that should get downloaded is the p4a source code update which should indeed be incremental (git pull) and minimalsak96 commentedon Jun 3, 2020
Ok. Will try it out. I may need a day or two to test it out. Hope the delay is not a issue. If it is you may mark the issue as closed.
sak96 commentedon Jun 5, 2020
@AndreMiras
I think java linter will really be helpful in pipeline. may be this stackoverflow link might help. Not a java developer so I am not sure of any good tools.
The issue i was facing was in
pythonforandroid/bootstraps/webview/build/src/main/java/org/kivy/android/PythonActivity.java.But fixed
pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.javain #2229.Note: There is third
PythonActivity.javafile in the diff you mentioned here.I did not familiarize with the project structure but now i see how things are structured. I think it is better if you fix the error. I may need more time due some network issue with my ISP.
Thanks
sak96 commentedon Jun 5, 2020
Lesson learned here is test before raising PR. (Again network issue) 😭
AndreMiras commentedon Jun 5, 2020
Thanks for testing it. So I understand it's fixed for webview, but some other files still has the issue?
Completely agree for the linter and it's in my task list. I actually have something ready-ish in local, but I'd like my other PR to be approved so I can merge and move forward with more stuff. I don't like piling too many PRs
sak96 commentedon Jun 5, 2020
Sorry for confusing you @AndreMiras
I fixed the issue for sdl2 type of bootstrap. But bug for webview still exists.
AndreMiras commentedon Jun 5, 2020
ahah true that, I overlooked it. I'll make a PR. Actually the sdl2 one was not needed, so I'll revert :)
🐛 Fixes service_only and webview symbol errors, closes kivy#2228
sak96 commentedon Jun 5, 2020
I also figured it now.
My bad. I feel so sheepish.
I remember checking it twice weather the keyevent was referenced in same file. I got confused.
Sorry for that.
AndreMiras commentedon Jun 5, 2020
No worries, that's my bad for also overlooking it. At least you made a comprehensive bug report and you gave it a try to fix it. Thanks again
Merge pull request #2233 from AndreMiras/feature/ticket2228_fix_symbo…
mnba commentedon Aug 6, 2020
The current release and latest 'develop' branch both are failed to be built, because of this persisting error, and the only way to make this working was that original way as it was on the day 1:
<<<Solution (or workaround)
frnsys commentedon Sep 27, 2020
I was running into this issue too. @mnba's answer worked for me.
🐛 Fixes service_only and webview symbol errors, closes kivy#2228
harish1996 commentedon Mar 6, 2021
I was also running into the same issue too, and this small patch seems to fix it. Thanks
I installed the python-for-android from pip. Is it in a older version than this fix ?
🐛 Fixes service_only and webview symbol errors, closes kivy#2228
epsi95 commentedon Jul 26, 2021
I also faced the same issue, which seems still not fixed.
obfusk commentedon Jul 26, 2021
Wasn't this fixed on
develop?epsi95 commentedon Jul 26, 2021
I tried with this getting started https://python-for-android.readthedocs.io/en/latest/quickstart/ and installed p4a via pip, seems the issue is still there.
obfusk commentedon Jul 26, 2021
Yes. And that should be fixed. But using
p4a.branch = developworks right now afaik :)