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

Update: Setup apk debugger #12

Closed
achille-martin opened this issue Aug 8, 2023 · 3 comments
Closed

Update: Setup apk debugger #12

achille-martin opened this issue Aug 8, 2023 · 3 comments

Comments

@achille-martin
Copy link
Owner

My current way of debugging the .apk is to:

  • Test extensively on Ubuntu via the python tools
  • Run .apk in an Android Emulator

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
Copy link
Owner Author

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

@achille-martin
Copy link
Owner Author

achille-martin commented Aug 8, 2023

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:

  • You have Vt-x (or equivalent) enabled and running your laptop: BlueStacks tips
  • Make sure that Hyper-V is disabled in Win10: use the bcdedit command to turn the feature on/off Nakivo blog -> from the CMD bcdedit /set hypervisorlaunchtype off and to re-enable it BCDEDIT /Set {current} hypervisorlaunchtype auto. Note that having Hyper-V off degrades performance of VirtualBox itself so you want to keep it on when not testing.

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

  • sudo apt install qemu-kvm
  • ls -al /dev/kvm
  • sudo adduser <Replace with username> kvm
  • sudo chown <Replace with username> /dev/kvm

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.
👍 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.
👍 WORKED

@achille-martin
Copy link
Owner Author

achille-martin commented Aug 8, 2023

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

  • The app is installed on the virtual device
  • adb is connected to the virtual device: adb devices
  • Run adb logcat *:<debug_level> where for instance <debug_level> is W for WARNING

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).

@achille-martin achille-martin changed the title Extra: Setup apk debugger Update: Setup apk debugger Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant