OSMDroid pacakge missing
mjoy99 opened this issue · comments
Describe the bug
when adding a toga.mapview and running on connected device I get the error osmdroid is missing. The app runs fine on devleopment platform
Steps to reproduce
briefcase create android
briefcase build android
briefcase run android
- Select andrpid from list
source code for app.py:
"""
My first application
"""
import toga
from toga.style import Pack
from toga.style.pack import COLUMN, ROW
class HelloWorld(toga.App):
def startup(self):
main_box = toga.Box(style=Pack(direction=COLUMN))
name_label = toga.Label(
"Your name: ",
style=Pack(padding=(0, 5))
)
self.name_input = toga.TextInput(style=Pack(flex=1))
name_box = toga.Box(style=Pack(direction=ROW, padding=5))
name_box.add(name_label)
name_box.add(self.name_input)
button = toga.Button(
"Say Hello!",
on_press=self.say_hello,
style=Pack(padding=5)
)
mapview = toga.MapView(location=(51.507222, -0.1275))
main_box.add(name_box)
main_box.add(button)
main_box.add(mapview)
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = main_box
self.main_window.show()
def say_hello(self, widget):
self.main_window.info_dialog(
f"Hello, {self.name_input.value}",
"Hi there!")
def main():
return HelloWorld()```
### Expected behavior
app should run and display a mapview
### Screenshots
_No response_
### Environment
- Operating System: Ubuntu 22.04.4 LTS
- Python version: 3.10.12
- Software versions:
- Briefcase: 0.3.18
- Toga: 0.4.4
- ...
### Logs
E/AndroidRuntime: FATAL EXCEPTION: main
E/AndroidRuntime: Process: com.example.helloworld, PID: 16384
E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloworld/org.beeware.android.MainActivity}: com.chaquo.python.PyException: RuntimeError: Unable to import MapView. Ensure that the OSMDroid Android system package (org.osmdroid:osmdroid-android:6.1.0) is listed in your app's dependencies.
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4164)
E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4322)
E/AndroidRuntime: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
E/AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
E/AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685)
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:230)
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:319)
E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8893)
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
E/AndroidRuntime: Caused by: com.chaquo.python.PyException: RuntimeError: Unable to import MapView. Ensure that the OSMDroid Android system package (org.osmdroid:osmdroid-android:6.1.0) is listed in your app's dependencies.
E/AndroidRuntime: at .toga_android.widgets.mapview.create(mapview.py:42)
E/AndroidRuntime: at .toga_android.widgets.base.init(base.py:55)
E/AndroidRuntime: at .toga.widgets.mapview.init(mapview.py:158)
E/AndroidRuntime: at .helloworld.app.startup(app.py:31)
E/AndroidRuntime: at .toga.app._startup(app.py:636)
E/AndroidRuntime: at .toga_android.app.create(app.py:199)
E/AndroidRuntime: at .toga_android.app.main_loop(app.py:232)
E/AndroidRuntime: at .toga.app.main_loop(app.py:614)
E/AndroidRuntime: at .main.(main.py:4)
E/AndroidRuntime: at .runpy._run_code(runpy.py:86)
E/AndroidRuntime: at .runpy._run_module_code(runpy.py:96)
E/AndroidRuntime: at .runpy.run_module(runpy.py:224)
E/AndroidRuntime: at .chaquopy_java.call(chaquopy_java.pyx:354)
E/AndroidRuntime: at .chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrowsNative(chaquopy_java.pyx:326)
E/AndroidRuntime: at com.chaquo.python.PyObject.callAttrThrowsNative(Native Method)
E/AndroidRuntime: at com.chaquo.python.PyObject.callAttrThrows(PyObject.java:232)
E/AndroidRuntime: at com.chaquo.python.PyObject.callAttr(PyObject.java:221)
E/AndroidRuntime: at org.beeware.android.MainActivity.onCreate(MainActivity.java:85)
E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8944)
E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:8913)
E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1456)
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4146)
E/AndroidRuntime: ... 12 more
### Additional context
_No response_
This suggests you're missing the package dependency that provides osmdroid; is org.osmdroid:osmdroid-android:6.1.0
specified in the dependencies in build_gradle_dependencies
?
Along with the text of the error message above, this is documented in the MapView docs.
I completely missed that part in the documentation. I updated the project.toml and was able to get it to work. Although, I couldn't get it to add the dependency through any of the below. Not sure how you get gradle to see it has updated dependency requirements.
I tried:
briefcase update android -r
briefcase build android -u
briefcase create android
and a few others, but until I deleted the android build and did the create again, I couldn't get the depency to add in.