PySide6-to-Android icon indicating copy to clipboard operation
PySide6-to-Android copied to clipboard

Compiled app crashing on startup

Open JonZavialov opened this issue 1 year ago • 8 comments

Hi Johannes, thanks for building these wheels. I have two questions:

  1. I compiled the app and installed it on my phone. When I try to open it, it is instantly crashing. Is there a way for me to see the logs, or read debug information to see why this is happening?
  2. How do I specify python dependencies for my project? I am not compiling the app and developing it on the same computer, so it doesn't have the dependencies installed. This is probably what's causing it to crash.

JonZavialov avatar Jul 17 '24 21:07 JonZavialov

Hi,

  • You can log the errors using "adb logcat --regex '<your app package name. Probably 'main.org' by default>"
  • The Android studio using the "Profile or debug an APK" tool. Just search Online, it's really easy to set up. (2 minutes max.)

It was actually descrtibed in the guide. You need to modify your PySide6 installation. I hope you have it installed through virtualenv. If yes, then you just need to go inside your virtual environment folder and then into /lib/python3.11/site-packages/PySide6/scripts/. Now modify the android_deploy.py script by using any editor of your choice. Search for the line run buildozer. Above this line write an input statement. Just something like input("Don't know lol") and then execute the build process as usual. When the script starts you'll see your input statement comming up. At this moment there should be a new file in your current directory named buildozer.spec. Edit this file. You'll see a line saying requirements = ... The last option there should be PySide6. You can just add another comma and add your dependencies (all by comma separated). You can also specify version numbers or compile them from git like you would normally do. If you need additional help I can also record a video for you to easily show you everything.

EchterAlsFake avatar Jul 17 '24 23:07 EchterAlsFake

Thanks for your help, I really appreciate it! I used your wheels with the tutorial from here. I'll try your tutorial tomorrow and update this thread.

JonZavialov avatar Jul 17 '24 23:07 JonZavialov

Here is my process (I am using Ubuntu 22.04):

  • Create a virtual environment- I downloaded Python 3.11 from deadsnakes/ppa, but couldn't create a venv the normal way. I realized you also need to run sudo apt install python3.11-venv. Then it works.
  • Install python dependencies, make sure it runs on the machine. I had to switch my PySide6 version to 6.7.1 and make sure everything was working with this version.
  • Create a separate venv for compiling, clone pyside-setup 6.7.2, install requirements.
  • Add input() to line 132 of venv/lib/python3.11/site-packages/PySide6/scripts/android_deploy.py
  • Make dist folder in pyside-setup, download wheels for PySide6 and Shiboken
  • Run pyside6-android-deploy with arguments (I already had NPK and SDK downloaded)
  • Add requirements to buildozer.spec.
  • Download APK on android, install app, run.

The app crashes on startup. I think this may have to do with my project structure, it might not be importing all the modules. In my main.py file, I am adding libraries outside of the directory to PATH. My directory looks like this:

Main project folder
└— Project
|   └— .env
|   └— Project (this was the directory I ran pyside6-android-deploy in)
|       └— main.py
└— Library
|   └— assets
|       └— assets.qrc
|       └— assets.py (compiled from .qrc)
|       └— fonts folder containing .ttf files
|       └— images folder containing .svg files

Here is the log from adb logcat:

07-18 09:58:31.970  1148  2156 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.main.main/org.kivy.android.PythonActivity bnds=[350,48][460,151]} from uid 10110
07-18 09:58:32.058  1148  1217 I ActivityManager: Start proc 17685:org.main.main/u0a163 for activity {org.main.main/org.kivy.android.PythonActivity}
07-18 09:58:35.489  1148  1167 W ActivityTaskManager:   Force finishing activity org.main.main/org.kivy.android.PythonActivity
07-18 09:58:35.991  1148  1209 W ActivityTaskManager: Activity top resumed state loss timeout for ActivityRecord{89de6a1 u0 org.main.main/org.kivy.android.PythonActivity t-1 f}
07-18 09:59:04.729  1148  2156 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.main.main/org.kivy.android.PythonActivity bnds=[350,48][460,151]} from uid 10110
07-18 09:59:04.777  1148  1210 W WindowManager: Token{5148f2d ActivityRecord{a877244 u0 org.main.main/org.kivy.android.PythonActivity t122}} failed creating starting window
07-18 09:59:04.777  1148  1210 W WindowManager: android.view.InflateException: Binary XML file line #35 in android:layout/screen_simple: Binary XML file line #35 in android:layout/screen_simple: Error inflating class <unknown>
07-18 09:59:04.777  1148  1210 W WindowManager: Caused by: android.view.InflateException: Binary XML file line #35 in android:layout/screen_simple: Error inflating class <unknown>
07-18 09:59:04.777  1148  1210 W WindowManager: Caused by: java.lang.reflect.InvocationTargetException
07-18 09:59:04.777  1148  1210 W WindowManager:         at java.lang.reflect.Constructor.newInstance0(Native Method)
07-18 09:59:04.777  1148  1210 W WindowManager:         at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.createView(LayoutInflater.java:854)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.createView(LayoutInflater.java:776)
07-18 09:59:04.777  1148  1210 W WindowManager:         at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.onCreateView(LayoutInflater.java:930)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.onCreateView(LayoutInflater.java:950)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
07-18 09:59:04.777  1148  1210 W WindowManager:         at com.android.internal.policy.DecorView.onResourcesLoaded(DecorView.java:2086)
07-18 09:59:04.777  1148  1210 W WindowManager:         at com.android.internal.policy.PhoneWindow.generateLayout(PhoneWindow.java:2627)
07-18 09:59:04.777  1148  1210 W WindowManager:         at com.android.internal.policy.PhoneWindow.installDecor(PhoneWindow.java:2694)
07-18 09:59:04.777  1148  1210 W WindowManager:         at com.android.internal.policy.PhoneWindow.getDecorView(PhoneWindow.java:2094)
07-18 09:59:04.777  1148  1210 W WindowManager:         at com.android.server.policy.PhoneWindowManager.addSplashScreen(PhoneWindowManager.java:2538)
07-18 09:59:04.777  1148  1210 W WindowManager:         at com.android.server.wm.SplashScreenStartingData.createStartingSurface(SplashScreenStartingData.java:56)
07-18 09:59:04.777  1148  1210 W WindowManager:         at com.android.server.wm.AppWindowToken$1.run(AppWindowToken.java:2230)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.os.Handler.handleCallback(Handler.java:883)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.os.Handler.dispatchMessage(Handler.java:100)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.os.Looper.loop(Looper.java:214)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.os.HandlerThread.run(HandlerThread.java:67)
07-18 09:59:04.777  1148  1210 W WindowManager:         at com.android.server.ServiceThread.run(ServiceThread.java:44)
07-18 09:59:04.777  1148  1210 W WindowManager: Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 35: TypedValue{t=0x2/d=0x1010059 a=-1}
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:997)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.content.res.TypedArray.getDrawable(TypedArray.java:981)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.View.<init>(View.java:5735)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.view.ViewGroup.<init>(ViewGroup.java:675)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.widget.FrameLayout.<init>(FrameLayout.java:99)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.widget.FrameLayout.<init>(FrameLayout.java:94)
07-18 09:59:04.777  1148  1210 W WindowManager:         at android.widget.FrameLayout.<init>(FrameLayout.java:89)
07-18 09:59:04.777  1148  1210 W WindowManager:         ... 26 more
07-18 09:59:04.832  1148  1217 I ActivityManager: Start proc 17750:org.main.main/u0a163 for activity {org.main.main/org.kivy.android.PythonActivity}
07-18 09:59:08.224  1148  2783 W ActivityTaskManager:   Force finishing activity org.main.main/org.kivy.android.PythonActivity
07-18 09:59:08.727  1148  1209 W ActivityTaskManager: Activity top resumed state loss timeout for ActivityRecord{a877244 u0 org.main.main/org.kivy.android.PythonActivity t122 f}
07-18 09:59:08.729  1148  1209 W ActivityTaskManager: Activity pause timeout for ActivityRecord{a877244 u0 org.main.main/org.kivy.android.PythonActivity t122 f}

JonZavialov avatar Jul 18 '24 14:07 JonZavialov

You did everything right. It's an error from Android. I would recommend you to use Pyside 6.7.2. I will compile the wheels in the evening (in 3-4 hours) and then you can try with them :)

Edit: I won't make it the next hour. Please wait a bit more, but I'll do it this session

EchterAlsFake avatar Jul 18 '24 14:07 EchterAlsFake

Sounds good, thank you!

JonZavialov avatar Jul 18 '24 14:07 JonZavialov

So I've released 6.7.2 now.

Although when I tried to start my App with them I got an error, but it was different than yours and I think this error is more related to my app being just very weird xD.

But to be honest, this whole Android project is very experimental and still not in a good state. When Qt started this last year in April I really had a lot of hope, but it didn't work. Nothing worked, not even their install script. And it doesn't work 1 year later if you don't know that you need to set the --verbose flag. Hopefully they fix that at some point...

Good luck.

EchterAlsFake avatar Jul 19 '24 01:07 EchterAlsFake

Yeah, lots of potential but the whole release seems very rushed and untested. I don't think anyone is actually using it right now. I tried your new wheels but same thing, app crashes on startup with the same error. I'll tinker some more with my project and see if I can get it to work, thanks so much for your help!

JonZavialov avatar Jul 19 '24 11:07 JonZavialov

Hi, since Qt has released Version 6.8 a lot of things got better. Maybe you could try again xD

(just to remind you lol)

EchterAlsFake avatar Oct 14 '24 20:10 EchterAlsFake