EchterAlsFake / PySide6-to-Android

a guide on how to compile a PySide6 (Qt for Python) application for Android devices.
21 stars 6 forks source link

Compiled app crashing on startup #3

Open JonZavialov opened 1 month ago

JonZavialov commented 1 month ago

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.
EchterAlsFake commented 1 month ago

Hi,

1)

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

JonZavialov commented 1 month ago

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 commented 1 month ago

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

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}
EchterAlsFake commented 1 month ago

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

JonZavialov commented 1 month ago

Sounds good, thank you!

EchterAlsFake commented 1 month ago

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.

JonZavialov commented 1 month ago

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!