Skip to content

Execution failed for task ':compileDebugJavaWithJavac'. "DialogInterface", "AlertDialog" and "KeyEvent" not found. #2228

Closed
@sak96

Description

@sak96

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 --debug

Spec 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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions