VM 0.5: No module named _sqlite3 in created APK file

114 views
Skip to first unread message

Lubo Kendra

unread,
Jan 27, 2019, 2:30:40 PM1/27/19
to Kivy users support
Hi all.
Thanks ZEN-Code and his great work with VM 0.5 i was able to successfully create my working apk file.
My app uses sqlite3 module: <from sqlite3 import dbapi2 as sqlite>. When i run my script in VM <python3 main.py>, ewerythig's fine, but my created APK file crashes with "no module found named _sqlite3" in adb catlog. I tried putting sqlite3 before python3 in requirements in buildozer.spec file with no success and the same error.
Here is my buildozer.spec file: 
Thanks in advance
LK

Lubo Kendra

unread,
Jan 28, 2019, 6:46:38 AM1/28/19
to Kivy users support
My logcat here:
  1. 01-28 12:39:04.302  6054  6082 I python  :   File "main.py", line 74, in <module
  2. >
  3. 01-28 12:39:04.304  6054  6082 I python  :     from sqlite3 import dbapi2 as sql
  4. ite
  5. 01-28 12:39:04.305  6054  6082 I python  :   File "/data/user/0/komfos.sk.invent
  6. ura2/files/app/_python_bundle/stdlib.zip/sqlite3/__init__.py", line 23, in <modu
  7. le>
  8. 01-28 12:39:04.306  6054  6082 I python  :   File "/data/user/0/komfos.sk.invent
  9. ura2/files/app/_python_bundle/stdlib.zip/sqlite3/dbapi2.py", line 27, in <module
  10. >
  11. 01-28 12:39:04.307  6054  6082 I python  : ModuleNotFoundError: No module named
  12. '_sqlite3'



Dňa nedeľa, 27. januára 2019 20:30:40 UTC+1 Lubo Kendra napísal(-a):

Alexander Taylor

unread,
Jan 28, 2019, 8:46:09 AM1/28/19
to Kivy users support
Could you post the full build log? I may have recently fixed a bug relating to this in python-for-android's master branch.

Lubo Kendra

unread,
Jan 28, 2019, 11:56:24 AM1/28/19
to Kivy users support
Hi,
logfile is litlebit verbose:
I hope it will be enough.

Dňa pondelok, 28. januára 2019 14:46:09 UTC+1 Alexander Taylor napísal(-a):

Robert Flatt

unread,
Jan 28, 2019, 6:50:16 PM1/28/19
to Kivy users support
Try reinstalling python-for-android, you may not have Alexander's fixes.
Using a version downloaded a week ago I found the 'sqlite3' requirement resulted in these files in the apk

sqlite3 :
    lib
/armeabi-v7a/libsqlite3.so
    assets
/_python_bundle/modules/_sqlite3.cpython-37m.so

So I think it can work.

Lubo Kendra

unread,
Jan 29, 2019, 3:15:43 AM1/29/19
to Kivy users support
Hi.
I tried reainstaling (cloning from git hub) p4a into path in previous version od p4a. Here are several last lines of buildozer log:
  1. [INFO]:    Selecting java build tool:
  2. [INFO]:    Detected highest available build tools version to be 28.0.2
  3. [INFO]:        Building with gradle, as gradle executable is present
  4. [DEBUG]:   -> running gradlew assembleDebug
  5. [DEBUG]:    Starting a Gradle Daemon (subsequent builds will be faster)
  6. [DEBUG]:    
  7. [DEBUG]:    > Task :compileDebugJavaWithJavac
  8. [DEBUG]:    Note: Some input files use or override a deprecated API.
  9. [DEBUG]:    Note: Recompile with -Xlint:deprecation for details.
  10. [DEBUG]:    Note: Some input files use unchecked or unsafe operations.
  11. [DEBUG]:    Note: Recompile with -Xlint:unchecked for details.
  12. [DEBUG]:    
  13. [DEBUG]:    
  14. [DEBUG]:    BUILD SUCCESSFUL in 1m 9s
  15. [DEBUG]:    27 actionable tasks: 27 executed
  16. [INFO]:    <- directory context /home/kivy/Repos/python-for-android
  17. [INFO]:    # Copying APK to current directory
  18. [INFO]:    # APK filename not found in build output. Guessing...
  19. [INFO]:    # Found APK file: /home/kivy/inventura2/.buildozer/android/platform/build/dists/inventura2/build/outputs/apk/debug/inventura2-debug.apk
  20. [INFO]:    # Add version number to APK
  21. [INFO]:    # APK renamed to inventura2-0.14-debug.apk
  22. [DEBUG]:   -> running cp /home/kivy/inventura2/.buildozer/android/platform/build/dists/inventura2/build/outputs/apk/debug/inventura2-debug.apk inventura2-0.14-debug.apk
  23. WARNING: Received a --sdk argument, but this argument is deprecated and does nothing.
  24. No compiled python is present to zip, skipping.
  25. Applying Java source code patches...
  26. Applying patch: src/patches/SDLActivity.java.patch
  27. Traceback (most recent call last):
  28.  File "/usr/local/bin/buildozer", line 9, in <module>
  29.    load_entry_point('buildozer', 'console_scripts', 'buildozer')()
  30.  File "/home/kivy/Repos/buildozer/buildozer/scripts/client.py", line 13, in main
  31.    Buildozer().run_command(sys.argv[1:])
  32.  File "/home/kivy/Repos/buildozer/buildozer/__init__.py", line 1059, in run_command
  33.    self.target.run_commands(args)
  34.  File "/home/kivy/Repos/buildozer/buildozer/target.py", line 92, in run_commands
  35.    func(args)
  36.  File "/home/kivy/Repos/buildozer/buildozer/target.py", line 104, in cmd_debug
  37.    self.buildozer.build()
  38.  File "/home/kivy/Repos/buildozer/buildozer/__init__.py", line 212, in build
  39.    self.target.build_package()
  40.  File "/home/kivy/Repos/buildozer/buildozer/targets/android.py", line 871, in build_package
  41.    copyfile(join(apk_dir, apk), join(self.buildozer.bin_dir, apk_dest))
  42.  File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
  43.    with open(src, 'rb') as fsrc:
  44. IOError: [Errno 2] No such file or directory: u'/home/kivy/inventura2/.buildozer/android/platform/build/dists/inventura2/build/outputs/apk/inventura2-debug.apk'
  45. kivy@kivy-complete:~/inventura2$

APK file is not in bin directory, but works weird - is always in landscape mode and fullscreen (in builodez.spec i have portrait mode and fullcsreen set to False.


Dňa utorok, 29. januára 2019 0:50:16 UTC+1 Robert Flatt napísal(-a):

Robert Flatt

unread,
Jan 30, 2019, 12:22:33 AM1/30/19
to Kivy users support
Congratulations, now you may find a few surprises!....

Seems one would expect landscape mode if portrait mode is false.
If you want both portrait and landscape you need to set ---- I don't know in buildozer, in p4a it is "--orientation sensor"
Probably best to leave fullscreen as default (I'm not certain that fullscreen really works, anybody?).

Lubo Kendra

unread,
Jan 31, 2019, 3:21:27 PM1/31/19
to Kivy users support
@Robert Flatt
Rotating solved using Plyer in my app (from Plyer import orientation...). Maybe sometimes later i will find better way to handle it.
Thak you for your usefull guide, that helping me a lot: https://groups.google.com/forum/#!topic/kivy-users/Lf4zlYmLVPo

Reply all
Reply to author
Forward
0 new messages