achille-martin / pyqt-crom

Create cross-platform apps (Android for now) using only Python and the Qt Framework (PyQt5 for now).
MIT License
29 stars 2 forks source link

Update: Setup apk debugger #12

Closed achille-martin closed 1 year ago

achille-martin commented 1 year ago

My current way of debugging the .apk is to:

The issue is that although the .apk is generated without bugs, it does not mean that it will work on an Android phone right away (ex: using wrong file system). Furthermore, I don't have access to crash logs.

Therefore, there is a need to find a tool to perform .apk debugging.

adb tool has been recommended.

achille-martin commented 1 year ago

Resources on how to setup adb for physical device testing: Julien's website.

achille-martin commented 1 year ago

Resources on how to setup Android Emulator in Android Studio on Ubnuntu: Expo dev website. Add these to your ~/.bashrc:

export ANDROID_HOME=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools

If you want to run an Emulator inside VirtualBox, you need to enable nested virtualisation: Oracle tips. If the nested virtualisation option is greyed-out in Windows: Stackoverflow website. Find your Virtual Box install folder thanks to Openwaterfoundation and find the name of your VM from the Virtual Box window app (Settings -> General -> Name). Use quotes " if your name contains spaces.

If you still have issues starting the emulator up in VirtualBox, make sure that:

If you have issues with /dev/kvm device permission denied: try the approach suggested on Stackoverflow:

If it is still too slow [VirtualBox tip didn't work for me], then setup Android Studio and Emulator on a proper Ubuntu desktop: follow the instructions from External dependencies setup. Note: install the latest version available, no need to restrict ourselves to Android 28. Note2: start the device from the device manager window create device. Note3: use recommended heap memory if suggested to run the app faster. :+1: WORKED

Once the Device emulator is working, drag and drop your .apk onto the virtual device. You can find the installed app in your list of available apps on the device. :+1: WORKED

achille-martin commented 1 year ago

To debug your .apk in Android Studio with adb, make sure that:

You can open the virtual device file manager by: View -> Tool Windows -> Device file explorer For instance, the ~ folder for your app is under: /data/data/org.qtproject.example.ExamplePyQt5DatabaseAndroidApp/files

You can view the content of your database (in the virtual device) by right cliking on the .db file (in the device file manager) and Saving the file to your laptop; then open the .db with sqlitebrowser (sudo apt-get install sqlitebrowser).