1

I'm following this howto to build an Android application with Python3 and Qt5. Nearly everything works fine but somehow I cannot find out how to set the application icon. In the documentation I could not find anything neither..

And just in case you know PyQtDeploy anyway.. how do I set the build mode from debug to release?

Backround:

pyqtdeploy-build creates the whole build-folder for Android (which contains all resources and AndroidManifest.xml) from scratch. Up to now I did not find a way to tell which icon to use. I would expect an option in the pyqtdeploy interface but there seems to be none..

Community
  • 1
  • 1
frans
  • 8,868
  • 11
  • 58
  • 132
  • To the downvoter: could you please elaborate on your thoughts? Do you know `pyqtdeploy` and find it easy to accomplish, what I'm asking for? – frans Apr 07 '20 at 06:35
  • I guess this just deploys a normal android application right? Shouldn't you then put the icon inside the proper `res` folders of the application, specify it in the `AndroidManifest` and once you hit the deploy command it should package with it. – Fred Apr 08 '20 at 08:35
  • As I just wrote - there is no `AndroidManifest.xml` or `res` folder in the first place. Both are being created by running `pyqtdeploy-build` which you run every time you want to build your application. This is why I was hoping you can specify the app icon in your sources.. – frans Apr 08 '20 at 08:47
  • oh I see. According to [this](https://stackoverflow.com/questions/26423150/qt-for-android-change-the-application-icon) there should be one, but I must confess I never actually coded a Qt project or even used pyQt. Maybe the link helps you out. Sorry if it doesn't. – Fred Apr 08 '20 at 09:43
  • Can you write a blog or make a video for developing for android? I followed the medium post but It didn't help me. – krmani Nov 20 '20 at 19:07
  • I'll do my very best - but allow some units of procrastination to pass :) – frans Nov 22 '20 at 11:14
  • 1
    @Infinyte7: I don't know if you get notified - let me know. I now managed to build the demo based on pyqtdeploy-3.1.0 at least for Linux now, Android is coming. See https://projects.om-office.de/frans/pyqt5_tools Unfortunately this setup has been far more difficult to set up then with Qt5.12 and pyqtdeploy-2.4 due to badly documented dependencies. If you see this comment have a look in the `docker/setup*.sh` files to see how to meet requirements for up to Qt5.15.2. Android is coming soon - maybe this weekend – frans Dec 04 '20 at 15:28
  • @frans Using @ I get notified. I haven't viewed your earlier comments. Thanks for sharing. – krmani Dec 04 '20 at 16:54

2 Answers2

1

Edit

I have never tried it but @Fred in comment above mentioned this way in Qt Creator - maybe it will work

Edit end

PyQtDeploy is designed for Python code and resources management. App icon is an Android framework thing, so you have to do it Android way - create resource in res folder and reference it in Android manifest.

You can automate the process though - you may create simple bash script that does the thing or one more Python build script with the same purpose - it takes icon from your location moves it to res folder and alters previously generated manifest with the correct reference in form of android:icon="@drawable/your_logo_name".

At least I was doing it like that.

And as a recommendation - if you want to use Python to develop under Android(and cross platform) use Kivy it is much more mature, supportable and complete with much bigger community. It is much faster and has more libs also.

Hope it helps.

Pavlo Ostasha
  • 14,527
  • 11
  • 35
0

In Android you find one res name folder if not create it their and refer to manifest file .

Now you have to put icon inside a drawable folder which is inside res folder

Your path follow look like :res>>>>drawable >>>icon.png

enter image description here

In case of Kivy it become twice eaiser

Your icon path needs to be either absolute or relative to your application file. So if your directory structure looks like this:

my_app/ ├── app.py └── things └── images └── my_icon.png

class MyApp:
    def build(self):
        self.icon = r'C:\Users\you\path\to\my_app\things\images\my_icon.png'
self.icon = r'things\images\my_icon.png'
Welcome_back
  • 1,245
  • 12
  • 18