android ios on the edge of qt and java objective c
play

Android & iOS on the edge of Qt and Java/Objective-C Maciej - PowerPoint PPT Presentation

Android & iOS on the edge of Qt and Java/Objective-C Maciej Wglarczyk Android & iOS on the edge of Qt and Java/Objective-C About me Cracow, Poland Graduated from AGH-UST with MSc in CS 6+ Qt years Game industry


  1. Android & iOS – on the edge of Qt and Java/Objective-C Maciej Węglarczyk

  2. Android & iOS – on the edge of Qt and Java/Objective-C About me Cracow, Poland ● Graduated from AGH-UST with MSc in CS ● 6+ Qt years ● Game industry ● Ganymede Ltd. (3 years+) ● Android & iOS lead ●

  3. Android & iOS – on the edge of Qt and Java/Objective-C The purpose of this talk Explain if / why one needs to write code beyond Qt ● Show what cannot be done with only Qt ● Give a taste of the way to communicate with native environments ● Give a brief overview how Qt is integrated with Android & iOS ●

  4. Android & iOS – on the edge of Qt and Java/Objective-C Agenda Reasons of extending Qt app with native code ● Needed tools ● Mixing Qt with Java/Objective-C ● Adding 3rd party libraries ● Modifying application entry point ●

  5. Android & iOS – on the edge of Qt and Java/Objective-C Beyond Qt “It's a dangerous business, Frodo, going out of your door” Bilbo Baggins

  6. Android & iOS – on the edge of Qt and Java/Objective-C EXTENDING? WHY?

  7. Android & iOS – on the edge of Qt and Java/Objective-C Importance of rich features Over 1,000,000 apps available in Google Play and Apple AppStore each ● Very demanding users ● Different ways of monetization ● Chances of being featured ● Increasing user engagement ● Virality ●

  8. Android & iOS – on the edge of Qt and Java/Objective-C Native integration - it's actually nothing new Qt Windows Extras , Qt Mac Extras, Qt X11 Extras ● Mobile OSes are evolving faster ● The problem is similar ●

  9. Android & iOS – on the edge of Qt and Java/Objective-C Where to start? First of all – know what you want and why ● Check if Qt supports it ● If not, check if it hasn't been done already by someone else... ● ...or if it couldn't be done by someone else in near future. :) ●

  10. Android & iOS – on the edge of Qt and Java/Objective-C What's not possible with Qt (at least for now) Notifications (push, rich) Alarms ● ● SMS API Communication with other apps ● ● Lock screen widgets Many useful 3rd party integrations ● ● Home screen widgets Facebook Connect ● ● Google Analytics Google / Apple API ● ● Monetization libs (i.e. Chartboost) Maps ● ● ... Game Services / Center ● ● Calendar ● ... ●

  11. Android & iOS – on the edge of Qt and Java/Objective-C Required tools Android iOS QtCreator QtCreator ● ● Some IDE for Java, i.e. Eclipse Xcode ● ● Android SDK & NDK Apple Developer Program Account ● ● Ant Xcode Command Line Tools ● ● Some devices Simulator is OK ● ● (emulator is still rather slow and sometimes unreliable) (devices are better, though)

  12. Android & iOS – on the edge of Qt and Java/Objective-C Useful tips Compile Output panel is much much more informative than Issues panel ● Android: QtCreator's Build command builds only Qt code, not Java yet ● Android: turn on the androiddeployqt's verbose option ●

  13. Android & iOS – on the edge of Qt and Java/Objective-C Basic Android / iOS projects Just take any of Qt 's examples for given platform ● Compile and run it from QtCreator ● That's it ●

  14. Android & iOS – on the edge of Qt and Java/Objective-C ADDING NATIVE CODE

  15. Android & iOS – on the edge of Qt and Java/Objective-C Adding native code – Android JNI – Java Native Interface ● Encapsulated into Qt 's androidextras module ● Containing a couple of useful classes and a namespace QtAndroid ● QT += androidextras QAndroidActivityResultReceiver QAndroidJniEnvironment QAndroidJniObject

  16. Android & iOS – on the edge of Qt and Java/Objective-C Adding native code – Android Both directions possible: ● C++ -> Java ● Java -> C++ ● <Example> https://github.com/FenixVoltres/ QtAndroidCpp2Java https://github.com/FenixVoltres/ QtAndroidJava2Cpp

  17. Android & iOS – on the edge of Qt and Java/Objective-C Adding native code – iOS It's very simple: Create some C++ class with normal header ● Use Objective-C in bodies of declared methods. ● That's all! ●

  18. Android & iOS – on the edge of Qt and Java/Objective-C Adding native code – iOS Following example taken from Richard Moe Gustavsen's ● talk on Qt for iOS from last year Qt DD 13 <Example> https://github.com/richardmg/ qtdd13_qmlapp

  19. Android & iOS – on the edge of Qt and Java/Objective-C How about Swift? C++ code can’t be executed from Swift directly ● Objective-C wrapper needed ● Swift -> Objective-C++ -> Qt

  20. Android & iOS – on the edge of Qt and Java/Objective-C ADDING NATIVE LIBRARIES

  21. Android & iOS – on the edge of Qt and Java/Objective-C Adding native libraries – Android Make sure you have defined ANDROID_PACKAGE_SOURCE_DIR variable in .pro file ● Add libs folder inside and put there all jars you want ● $PROJECT ● android-sources ● libs ● <put your jar here> ● <Example> https://github.com/FenixVoltres/ QtAndroidNativeLib

  22. Android & iOS – on the edge of Qt and Java/Objective-C Adding native libraries – iOS Even simpler: LIBS += -F/path/to/frameworks/folder LIBS += -framework StoreKit

  23. Android & iOS – on the edge of Qt and Java/Objective-C MODYFYING ENTRY POINT

  24. Android & iOS – on the edge of Qt and Java/Objective-C Why one would modify an entry point? Not whole application must be written in Qt ● To override some Qt 's behavior ● To make some actions before Qt is loaded ●

  25. Android & iOS – on the edge of Qt and Java/Objective-C Deployment process – Android A bit complicated ● Two overrided classes – QtActivity.java and QtApplication.java ● are copied to android build folder Located in $QT/android_xxx/src/android/java/src/org/qtproject/qt5 ● Used in AndroidManifest.xml ●

  26. Android & iOS – on the edge of Qt and Java/Objective-C Adding .java source files Define ANDROID_PACKAGE_SOURCE_DIR variable in .pro file, ● so it points to folder with Android internal folders structure (src, res, assets, libs) or let QtCreator does it for you Put all .java files in proper folder structure connected with their packages ● in src folder Put all other resources in proper folders – all of them will be copied into ● the final .apk file

  27. Android & iOS – on the edge of Qt and Java/Objective-C Modifying app’s entry point – Android AndroidManifest.xml can be changed – any different Activity can be an entry point. ● QtActivity and QtApplication can be overridden ● <Example> https://github.com/FenixVoltres/ QtAndroidSplash

  28. Android & iOS – on the edge of Qt and Java/Objective-C Deployment process – iOS Again, very simple ● Building a project creates Xcode project file in build folder ● It can be open an freely modified after QtCreator build. ● After any change in QtCreator the process must be repeated! ●

  29. Android & iOS – on the edge of Qt and Java/Objective-C Modifying app’s entry point – iOS Open Xcode project generated by QtCreator ● Modify what you want. ●

  30. Android & iOS – on the edge of Qt and Java/Objective-C WRAP UP

  31. Android & iOS – on the edge of Qt and Java/Objective-C Mixing Qt with native code Much easier on iOS than on Android ● Almost everything is possible ● Good luck!

  32. Android & iOS – on the edge of Qt and Java/Objective-C THANK YOU!

  33. Android & iOS – on the edge of Qt and Java/Objective-C Q t & A m Questions & Answers maybe Maciej Węglarczyk Maciej.Weglarczyk@gmail.com

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend