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

Support for Android AAB (Armv7 & Armv8) #145

Closed
chaunnt opened this issue Feb 11, 2020 · 6 comments
Closed

Support for Android AAB (Armv7 & Armv8) #145

chaunnt opened this issue Feb 11, 2020 · 6 comments

Comments

@chaunnt
Copy link

chaunnt commented Feb 11, 2020

Thank you for your effort up to this.
I am making a simple project (news app) with QtFirebase using firebase messaging and analytics.
Google Play Store now require to upload AAB (or APK with ARMv8 only).
My source code was fine with building APK for both ARMv8, ARMv7, x86 and iOS.
But when i change to make AAB, a lot errors come out.
It may be linking error or something in Qt firebase (using .pri files, not tried .pro), other plugins of mine are fine with this.

Screenshot from 2020-02-11 10-10-16

Can you take a look ?
I also investigate it as well
-> I will try to fix libc++ linking ( i think this lib is broken when go with AAB)
-> I also try to use pro file.

My environment

  • Ubuntu 18.04
  • QtCreator 4.11.rc (preview)
  • Qt 5.14.1
  • Firebase 16.0 (latest up to now)
  • QtFirebase 1.2.7
@larpon
Copy link
Owner

larpon commented Feb 11, 2020

Hi @chaunnt,

I haven't had the guts to use the AAB feature yet as the Qt support for it is in a way too early stage/bleeding edge to my liking. Personally I use multiple APK's for all my projects. That said I can't see why it shouldn't work because of QtFirebase? Latest QtFirebase (master branch) builds fine individually with all supported arch's on my setup.

Judging from your output there seem to be a mix of Android NDK's?
I see both r16b and r20 in the output? I've had similar vtable errors in one of my projects but at this time of writing I can't remember how I fixed them - stackoverflow will probably give you some hints. I think it was something with the toolchain using the wrong paths when compiling for arm64_v8a (I.e armv7a and arm64_v8a was used/mixed in the build phase). Try using Android NDK r20 only and double check your paths - and see if that will solve your problems?

Happy bug hunt!

@larpon
Copy link
Owner

larpon commented Feb 11, 2020

Updated answer ^

@chaunnt
Copy link
Author

chaunnt commented Feb 12, 2020

SOLVED MY SELF.
PUT IT HERE IF ANYONE NEED IT
Scenario: build QtFirebase using .pri with AAB support ARMv7 & ARMv8 (and both x86, x86_64 but not tested yet)
Environments:

  • Qt 5.14.1
  • QtCreator 4.11.rc (preview)
  • Firebase (latest up to now 6.9 or something)
  • QtFirebase 1.2.7
  • gradle:3.5.0
    Projects: Qt Subdirs Projects with Quick application & 5 Qt plugins library & pre-built SSL Libraries

problem is about linking libc++.
In baseapp.pro -> disable QMAKE_LFLAGS += -nostdlib++ line or add !versionAtLeast(QT_VERSION, "5.14.0"): QMAKE_LFLAGS += -nostdlib++ (or both if use want it)

Some other problems will come from building old project with new format of Android SDK and QtCreator.
Here are few steps you need to:

  1. Backup your android source in ANDROID_PACKAGE_SOURCE_DIR.
  2. Using QtCreator to create template AndroidManifest.xml(BEWARE: new manifest use some meta for lib / asset, make sure you have it in your project or delete it and use old source)
  3. Merge all firebase com.google.firebase service from old manifest to generated manifest
  4. Merge all build.gradle to generated build.gradle
  5. in BaseApp.pro delete some configs if you had it in your code or QMAKE will generate wrong deployment.json file (I don't know why since the output is not changed :) )
  • TEMPLATE = app
  • TARGET = $$qtLibraryTarget($$TARGET)
  1. update your Path in .pri file of qtfirebase_target.pri
  • in -F$$QTFIREBASE_FRAMEWORKS_ROOT Latest firebase use Firebase<module> (ex: FirebaseMessaging) instead of (ex: Messaging) folder. update it if you use latest firebase
  • replace $$ANDROID_TARGET_ARCH to $${QT_ARCH} :) Same !! (Do not know why because they have same values when running qmake but it works =)) )
  1. in all of your pro / pri, if you include your plugins, change the linking of library to make sure library are built and link correctly with platforms
    Example:
    Old source
    LIBS += -L../GeneralPlugins/ -lGeneralPlugins
    ANDROID_EXTRA_LIBS += $$OUT_PWD/../GeneralPlugins/libGeneralPlugins.so

Updated
LIBS += -L../GeneralPlugins/ -lGeneralPlugins_$${QT_ARCH}
ANDROID_EXTRA_LIBS += $$OUT_PWD/../GeneralPlugins/libGeneralPlugins_$${QT_ARCH}.so

That's all :) you will have them on store
Read more about format of structure of AAB if you need to add anything to native Android.
https://developer.android.com/guide/app-bundle?authuser=1

@larpon
Copy link
Owner

larpon commented Feb 14, 2020

@chaunnt - thanks for posting a solution. I will have an extra look - and see if we can detect AAB builds somehow and make this easier

@chaunnt
Copy link
Author

chaunnt commented Feb 16, 2020

Sad to say... Qt5.14 have bugs on AAB build format, this cause app crash on launching (Store upload is ok. )

Currently, I still use APK build with multi APKs upload for a release.

NOTE for all :)

@davidzwa
Copy link

davidzwa commented Jul 24, 2020

I got the build on Android with Qt 5.14.2 working in AAB bundle for armv7 and armv8 (not x86 targets). To be found on QtFirebaseExample as a PR which cannot be closed due to complexity, but still serves a working example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants