ModuleNotFoundError: No module named 'android'

215 views
Skip to first unread message

godir...@gmail.com

unread,
Nov 3, 2023, 3:48:42 AM11/3/23
to Kivy development
Guys i do not know know where to go because the kivy google group has been shut down (https://groups.google.com/g/kivy-users) so i'm here because I have this persistent error that wont go away and I think i've done all I can but its still here I need help!!!

I'm trying to use WebView on my app but when I run the code I get this error:
Traceback (most recent call last):
     from android.runnable import run_on_ui_thread
 ModuleNotFoundError: No module named 'android'

from jnius import autoclass
from android.runnable import run_on_ui_thread
from kivy.uix.widget import Widget

WebView = autoclass('android.webkit.WebView')
WebViewClient = autoclass('android.webkit.WebViewClient')
activity = autoclass('org.kivy.android.PythonActivity').mActivity

@run_on_ui_thread
    def open_website(self, dt):
        webview = WebView(activity)
        webview.getSettings().setJavaScriptEnabled(True)
        wvc = WebViewClient();
        webview.setWebViewClient(wvc);
        activity.setContentView(webview)
        webview.loadUrl("https://www.google.com/")  

Alchemist

unread,
Nov 3, 2023, 4:02:29 AM11/3/23
to kivy...@googlegroups.com
Hello dear, your code is fine... Note the point ha....
>> The "android" package, which you are importing is not included in kivy package or in python itself.

>> In this case, the package can only be imported from Android operating system.

>> For this, you need to build the .apk file of your code. and run it in an Android platform.

>> To avoid errors while running in your development platform do this:
          from kivy.platform import platform
          if platform=='android':
                  import android.....
                  ....and related code....

🙂hope you got the point.

--
You received this message because you are subscribed to the Google Groups "Kivy development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-dev/717ba087-3541-4f32-a13d-d0e9eedb4ccdn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages