briefcase: Android gradle build fails for application
I was trying to build a simple dummy app using toga and packaging it with briefcase for different platforms. The simple app opens a blank window (source code below)
import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW
class Freedom(toga.App):
def startup(self):
# Create a main window with a name matching the app
self.main_window = toga.MainWindow(self.name)
# Create a main content box
main_box = toga.Box()
# Add the content on the main window
self.main_window.content = main_box
# Show the main window
self.main_window.show()
def main():
return Freedom('Freedom', 'com.example.freedom')
The build succeeds for macOS and linux platforms and runs fine on these platforms (i didn’t try others yet) but fails for android. I am working on Mac OS Sierra with python 3.6, toga.version 0.3.0.dev8 , briefcase.version 0.2.1 To setup the development environment for android I installed Android Studio (v 3.0.1) downloaded sdk 15 and 25. I set up the ANDROID_HOME environment and PATH variables as described in https://media.readthedocs.org/pdf/briefcase/latest/briefcase.pdf (page 14, android section)
Running python setup.py android
successfully creates the android folder with the output
Installing collected packages: freedom
Running setup.py install for freedom ... done
Successfully installed freedom-0.0.1
* No icons defined - using default...
* No splash screen defined...
Installation complete.
To compile, install and run the project on your phone:
$ cd android
$ ./gradlew run
The error occurs when using gradlew.
If I run gradlew build
or gradlew run
, the process ends with the error message
Problem occurred in toga/handlers.py
Node: YieldFrom(value=Call(func=Attribute(value=Name(id='asyncio', ctx=Load(), lineno=19, col_offset=23), attr='sleep', ctx=Load(), lineno=19, col_offset=23), args=[
Name(id='delay', ctx=Load(), lineno=19, col_offset=37),
], keywords=[], lineno=19, col_offset=23), lineno=19, col_offset=12)
:buildPythonDebug FAILED
FAILURE: Build failed with an exception.
* Where:
Build file 'freedom/android/build.gradle' line: 15
* What went wrong:
Execution failed for task ':buildPythonDebug'.
> Process 'command 'voc'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 16.915 secs
Any idea what might be going wrong?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (4 by maintainers)
I can also confirm that the combination of Toga 0.2.15 and VOC 0.1.4 works great. thanks @donkirkby
OK, I found the problem. It looks like there’s a bug in VOC 0.1.5. Rolling back to 0.1.4 fixed it for me.
I’ll report a bug on the VOC project and link it back here, so I think you can close this one. Thanks for helping me track it down.
@donkirkby Toga Tutorials 0 and 1 (Hello World and Fahrenheit to Celsius) both worked on Toga 0.2.15 the last time I tested them. That was running under Android 6.0.1 on a Nexus 5.
This isn’t a problem with Briefcase; it’s a problem with VOC on Toga 0.3.0. The 0.3.0 branch of Toga includes some refactoring that hasn’t been fully rolled out into the Android backend. The failure is happening because Toga is using a language feature (
yield from
) that VOC doesn’t support. We need to make some updates to VOC to handle this language feature.