Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSMDroid pacakge missing #1796

Closed
mjoy99 opened this issue May 14, 2024 · 2 comments
Closed

OSMDroid pacakge missing #1796

mjoy99 opened this issue May 14, 2024 · 2 comments
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.

Comments

@mjoy99
Copy link

mjoy99 commented May 14, 2024

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

  1. briefcase create android
  2. briefcase build android
  3. briefcase run android
  4. 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_
@mjoy99 mjoy99 added the bug A crash or error in behavior. label May 14, 2024
@rmartin16
Copy link
Member

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.

@rmartin16 rmartin16 added android The issue relates to Android mobile support. awaiting details More details are needed before the issue can be triaged. labels May 14, 2024
@mjoy99
Copy link
Author

mjoy99 commented May 15, 2024

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.

@mjoy99 mjoy99 closed this as completed May 15, 2024
@rmartin16 rmartin16 removed the awaiting details More details are needed before the issue can be triaged. label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android The issue relates to Android mobile support. bug A crash or error in behavior.
Projects
None yet
Development

No branches or pull requests

2 participants